sem_timedwait error

Joel Sherrill joel.sherrill at oarcorp.com
Tue May 15 15:52:55 UTC 2007


Aitor.Viana.Sanchez at esa.int wrote:
>
> Hi,
>
> i am working with rtems 4.6 over LEON2 architecture. I got a problem 
> with the sem_timedwait POSIX function. This function has the next 
> declaration:
>
> int sem_timedwait(sem_t *restrict /sem/, const struct timespec 
> *restrict /abs_timeout/);
>
> the problem is that the abs_timeout must have the field tv_nsec 
> cleared (set to 0x0) otherwise the function is not executed correctly. 
> I think this is a bug in the POSIX API and I guess it would also 
> affect other platforms.
> Moreover, the problem is considerable for real-time systems because of 
> the lost of precision.
>
It looks like a bad edit in the error checking code.  It is the remains 
of code that
was trying to see if tv_sec or tv_nsec is < 0.  Try the attached patch.

This was probably introduced as part of fixing PR841.

FWIW the same code is in an "#if 0" block on the 4.7 branch and on the 
CVS head,
the error checking is done by a helper routine so it is the same 
everywhere.  I
saw this type of code in a lot of places and moved it to a common and 
hopefully
more correct routine.

Let me know if this works.

--joel


> Any idea ?
>
>
> Cheers,
>  
> Aitor
> ------------------------------------------------------------------------
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
>   

-------------- next part --------------
A non-text attachment was scrubbed...
Name: semtimedwait.c.diff
Type: text/x-patch
Size: 874 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/users/attachments/20070515/e15fc79b/attachment-0001.bin>


More information about the users mailing list