Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of rtos_semaphore by
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 00004 Semaphore two_slots(2); //Setup the use of two semaphores 00005 00006 void test_thread(void const *name) { //setup thread function 00007 while (true) { 00008 two_slots.wait(); //Wait to get a semaphore to use the 00009 printf("%s\n\r", (const char*)name); //when have semaphore printf on serial of thread number 00010 Thread::wait(1000); //thread wait 00011 two_slots.release(); //Release semaphore back to RTOS 00012 } 00013 } 00014 00015 int main (void) { 00016 Thread t2(test_thread, (void *)"Th 2"); //start thread 00017 Thread t3(test_thread, (void *)"Th 3"); //start thread 00018 00019 test_thread((void *)"Th 1"); //function call in main thread 00020 }
Generated on Sat Jul 23 2022 12:08:50 by
