MDK-ARM Keil, MDK-ARM Datasheet - Page 34

KIT REALVIEW MCU DEVELOPMENT

MDK-ARM

Manufacturer Part Number
MDK-ARM
Description
KIT REALVIEW MCU DEVELOPMENT
Manufacturer
Keil
Type
Compiler and IDEr
Datasheets

Specifications of MDK-ARM

For Use With/related Products
ARM MCUs
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
34
Using Semaphores
Although semaphores have a simple set of OS calls, they have a wide range of
synchronizing applications. This makes them perhaps the most challenging
RTOS objects to understand. In this section, we will look at the most common
uses of semaphores. Some are taken from “The Little Book Of Semaphores” by
Allen B. Downy, and may be freely downloaded from the URL given in the
bibliography at the end of this book.
Signaling
Synchronizing the execution of two tasks is the simplest use of a semaphore:
In this case, the semaphore is used to ensure that the code in FuncA() is executed
before the code in FuncB().
Multiplex
A multiplex semaphore limits the number of tasks that can access a critical
section of code. For example, routines that access memory resources and can
support a limited number of calls.
os_sem Multiplex;
void task1 (void) __task
}
os_sem semB;
__task void task1 (void)
}
os_sem_init (Multiplex, 5);
while (1)
}
os_sem_init (semB, 0);
while (1)
}
os_sem_wait (Multiplex, 0xFFFF);
ProcessBuffer ();
os_sem_send (Multiplex);
os_sem_send (semB);
FuncA();
{
{
{
{
__task void task2 (void)
}
while (1)
}
os_sem_wait (semB, 0xFFFF);
FuncB();
Chapter 2. Developing With an RTOS
{
{

Related parts for MDK-ARM