Lab 8 part 3

Dependencies:   mbed mbed-rtos

Revision:
13:a68509ad3202
Parent:
12:4e3f46e615d9
--- a/main.cpp	Mon Mar 30 18:54:14 2020 +0000
+++ b/main.cpp	Sun May 03 19:12:28 2020 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+#include "rtos.h"
+ 
+Semaphore two_slots(2);
+ 
+void test_thread(void const *name) {
+    while (true) {
+        two_slots.wait();
+        printf("%s\n\r", (const char*)name);
+        Thread::wait(1000);
+        two_slots.release();
+    }
+}
+ 
+int main (void) {
+    Thread t2;
+    Thread t3;
+ 
+    t2.start(callback(test_thread, (void *)"Th 2"));
+    t3.start(callback(test_thread, (void *)"Th 3"));
+ 
+    test_thread((void *)"Th 1");
+}
\ No newline at end of file