Slide 1 Slide 2 Slide 3 Slide 4 Slide 5 Slide 6 Slide 7 Slide 8 Slide 9 Slide 10 Slide 11 Product List
SYS/BIOS Semaphores Slide 11

In summary, Semaphores are often used to coordinate access to a shared resource among a set of competing tasks. They can be used for task synchronization and mutual exclusion. Semaphore objects can be declared as either counting or binary semaphores. The same APIs are used for both counting and binary semaphores. pend() is used to wait for a semaphore. The timeout parameter allows the task to wait until a timeout, wait indefinitely, or not wait at all. The return value is used to indicate if the semaphore was signaled successfully. post() is used to signal a semaphore. If a task is waiting for the semaphore, post() removes the task from the semaphore queue and puts it on the ready queue. If no tasks are waiting, post() simply increments the semaphore count and returns. For a binary semaphore the count is always set to one.

PTM Published on: 2012-07-19