semaphore example

Files at this revision

API Documentation at this revision

Comitter:
Jennifer Plunkett
Date:
Fri Feb 02 15:14:15 2018 -0600
Parent:
6:959c2b75861c
Commit message:
Fixed bug that made printf() unprotected

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 959c2b75861c -r 755dee0042c3 main.cpp
--- a/main.cpp	Fri Jun 23 14:46:38 2017 -0500
+++ b/main.cpp	Fri Feb 02 15:14:15 2018 -0600
@@ -1,15 +1,15 @@
 #include "mbed.h"
 
-Semaphore two_slots(2);
+Semaphore one_slot(1);
 Thread t2;
 Thread t3;
-    
+
 void test_thread(void const *name) {
     while (true) {
-        two_slots.wait();
+        one_slot.wait();
         printf("%s\n\r", (const char*)name);
         wait(1);
-        two_slots.release();
+        one_slot.release();
     }
 }