counting semaphore question

Joel Sherrill joel.sherrill at OARcorp.com
Sat Dec 21 13:33:56 UTC 2002


> Hi, all
>         When I using couning semaphore I'v some question not so clear. Could anyone give some advice? In application if I creat a counting semaphore and obtain it many times more than it's initial value, will its counting value decrease to be negative ? For example, if:
> 
>         /* initial value: 1 */  
>         rtems_semaphore_create( name, 1, RTEMS_DEFAULT_ATTRIBUTES, 1, &id );
> 
>         /* decrease to 0 ?  */
>         rtems_semaphore_obtain( id, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT ); 
> 
>         /* decrease to -1 ? */
>     rtems_semaphore_obtain( id, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT ); 
> 
>         Will the semaphore count be -1? 

No.

>Is there a return value or anything else to notify user that the semaphore count has come to its limitation?

Per the online documentation at
http://www.oarcorp.com/rtemsdoc-current/html/c_user/c_user00158.html
it returns RTEMS_UNSATISFIED 
 
>         TIA.
> 

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985




More information about the users mailing list