RTEMS Logo

RTEMS 4.9.2 On-Line Library


Semaphore Manager Acquiring a Semaphore

PREV UP NEXT Bookshelf RTEMS Ada User's Guide

9.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 Ada User's Guide

Copyright © 1988-2008 OAR Corporation