OAR

RTEMS 4.0.0 On-Line Library


Semaphore Manager Acquiring a Semaphore

PREV UP NEXT Bookshelf RTEMS C User's Guide

8.3.3: Acquiring a Semaphore

The rtems_semaphore_obtain directive is used to acquire the specified semaphore. A simplified version of the rtems_semaphore_obtain directive can be described as follows:

if semaphore's count is greater than zero
   then decrement semaphore's count
   else wait for release of semaphore

return SUCCESSFUL

When the semaphore cannot be immediately acquired, one of the following situations applies:

If the task waits to acquire the semaphore, then it is placed in the semaphore's task wait queue in either FIFO or task priority order. If the task blocked waiting for a binary semaphore using priority inheritance and the task's priority is greater than that of the task currently holding the semaphore, then the holding task will inherit the priority of the blocking task. All tasks waiting on a semaphore are returned an error code when the semaphore is deleted.

When a task successfully obtains a semaphore using priority ceiling and the priority ceiling for this semaphore is greater than that of the holder, then the holder's priority will be elevated.


PREV UP NEXT Bookshelf RTEMS C User's Guide

Copyright © 1988-1998 OAR Corporation