]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/tests/rtos/cmsis/mutex/main.cpp
5 osMutexDef(stdio_mutex
);
7 void notify(const char* name
, int state
) {
8 osMutexWait(stdio_mutex
, osWaitForever
);
9 printf("%s: %d\n\r", name
, state
);
10 osMutexRelease(stdio_mutex
);
13 void test_thread(void const *args
) {
15 notify((const char*)args
, 0); osDelay(1000);
16 notify((const char*)args
, 1); osDelay(1000);
20 void t2(void const *argument
) {test_thread("Th 2");}
21 osThreadDef(t2
, osPriorityNormal
, DEFAULT_STACK_SIZE
);
23 void t3(void const *argument
) {test_thread("Th 3");}
24 osThreadDef(t3
, osPriorityNormal
, DEFAULT_STACK_SIZE
);
27 stdio_mutex
= osMutexCreate(osMutex(stdio_mutex
));
29 osThreadCreate(osThread(t2
), NULL
);
30 osThreadCreate(osThread(t3
), NULL
);
32 test_thread((void *)"Th 1");