rtos4

Dependencies:   mbed-rtos mbed

Fork of rtos_basic by mbed official

Revision:
7:68fb4465a2c3
Parent:
3:c92e21f305d8
--- a/main.cpp	Tue Jun 04 16:01:32 2013 +0100
+++ b/main.cpp	Fri Nov 13 14:43:17 2015 +0000
@@ -1,21 +1,37 @@
 #include "mbed.h"
 #include "rtos.h"
- 
-DigitalOut led1(LED1);
-DigitalOut led2(LED2);
- 
-void led2_thread(void const *args) {
+
+Mutex mux;
+int a;
+
+
+void thread1(void const *args) {
+
     while (true) {
-        led2 = !led2;
-        Thread::wait(1000);
+            mux.lock();
+            a++;
+            printf("LOW %d \r\n",a);
+            mux.unlock();
     }
 }
- 
-int main() {
-    Thread thread(led2_thread);
-    
+
+void thread2(void const *args) {
+
     while (true) {
-        led1 = !led1;
-        Thread::wait(500);
-    }
+            mux.lock();
+            a++;
+            printf("HIGH %d \r\n",a);
+            mux.unlock();
+        }
 }
+
+int main() {
+    a = 0;
+    Thread my_thread1(thread1, NULL, osPriorityLow);
+    Thread::wait(10);
+    Thread my_thread2(thread2, NULL, osPriorityHigh);
+
+    while (true) {
+            printf("MEDIUM \r\n");
+        }
+}