]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/tests/rtos/cmsis/semaphore/main.cpp
4 osSemaphoreId two_slots
;
5 osSemaphoreDef(two_slots
);
7 void test_thread(void const *name
) {
9 osSemaphoreWait(two_slots
, osWaitForever
);
10 printf("%s\n\r", (const char*)name
);
12 osSemaphoreRelease(two_slots
);
16 void t2(void const *argument
) {test_thread("Th 2");}
17 osThreadDef(t2
, osPriorityNormal
, DEFAULT_STACK_SIZE
);
19 void t3(void const *argument
) {test_thread("Th 3");}
20 osThreadDef(t3
, osPriorityNormal
, DEFAULT_STACK_SIZE
);
23 two_slots
= osSemaphoreCreate(osSemaphore(two_slots
), 2);
25 osThreadCreate(osThread(t2
), NULL
);
26 osThreadCreate(osThread(t3
), NULL
);
28 test_thread((void *)"Th 1");