Demonstrates data corruption due to a race condition updated for mbed os 5.4

Fork of Task614-mbedos54 by Stage-1 Students SoCEM

Revision:
2:7e77fec81f7d
Parent:
1:8c6ec9de7688
--- a/main.cpp	Tue Mar 08 12:11:18 2016 +0000
+++ b/main.cpp	Thu Mar 30 14:12:06 2017 +0000
@@ -1,13 +1,12 @@
 #include "mbed.h"
-#include "rtos.h"
 
 #define RED_DONE 1
 #define YELLOW_DONE 2
 
 
 //Function declarations
-void countUP(void const *args);
-void countDOWN(void const *args);
+void countUP();
+void countDOWN();
 
 //Digital outputs
 DigitalOut onBoardLED(LED1);
@@ -27,7 +26,7 @@
 volatile long long count = 0;
 
 //Threads
-void countUP(void const *args)
+void countUP()
 {
     redLED = 1;
     
@@ -48,7 +47,7 @@
     osSignalSet(tidMain, RED_DONE);  //Signal main thread we are done
 }
 
-void countDOWN(void const *args)
+void countDOWN()
 {
     yellowLED = 1;
     
@@ -72,6 +71,8 @@
 
 //Main thread
 int main() {
+    Thread t1, t2;
+    
     redLED    = 0;
     yellowLED = 0;
     greenLED  = 1;
@@ -82,12 +83,12 @@
     //Press the switch to run concurrently
     if (onBoardSwitch == 1) {
         printf("Running sequntially\n");
-        countUP(NULL);
-        countDOWN(NULL);        
+        countUP();
+        countDOWN();        
     } else {
         printf("Running concurrently\n");
-        Thread t1(countUP);           
-        Thread t2(countDOWN);    
+        t1.start(countUP);           
+        t2.start(countDOWN);    
   
         //Wait for the ALL_ON signal
         Thread::signal_wait(RED_DONE,osWaitForever);