May 2020
Intermediate to advanced
496 pages
13h 54m
English
Binary semaphores are really just counting semaphores with a maximum count of 1. They are most often used for synchronization. When a task needs to synchronize on an event, it will attempt to take a semaphore, blocking until the semaphore becomes available or until the specified timeout has elapsed. Another asynchronous part of the system (either a task or an ISR) will give a semaphore. Binary semaphores can be given more than once; there is no need for that piece of code to return them. In the following example, TaskA only gives a semaphore, while TaskB only takes a semaphore:

TaskB is set up to wait for a signal (semaphore) ...