Demonstration of priority scheduling vs round robin

Dependencies:   ELEC350-Practicals-FZ429

Fork of Task621-mbedos54 by Nicholas Outram

Revision:
9:ac5a5458abe3
Parent:
8:2deeed44c6c3
--- a/main.cpp	Mon Apr 03 11:45:25 2017 +0000
+++ b/main.cpp	Thu Nov 09 15:19:28 2017 +0000
@@ -1,31 +1,19 @@
 #include "mbed.h"
-#include "rtos.h"
+
 #include "string.h"
 #include <stdio.h>
 #include <ctype.h>
+#include "sample_hardware.hpp"
 
 #define DELAY 200
 
-//Digital outputs
-DigitalOut onBoardLED(LED1);
-DigitalOut redLED(D7);
-DigitalOut yellowLED(D6);
-DigitalOut greenLED(D5);
-
-//Serial Interface
-Serial pc(USBTX, USBRX);
-
-//Digital inputs
-DigitalIn  onBoardSwitch(USER_BUTTON);
-DigitalIn  SW1(D4);
-DigitalIn  SW2(D3);
 
 //Thread ID for the Main function (CMSIS API)
 osThreadId tidMain;
 
 void thread1() 
 {
-    pc.printf("Entering thread 1\n");
+    printf("Entering thread 1\n");
     while (true) {
         yellowLED = 1;
         Thread::wait(DELAY);   
@@ -37,7 +25,7 @@
 //This thread has higher priority
 void thread2() 
 {
-    pc.printf("Entering thread 2\n");  
+    printf("Entering thread 2\n");  
     while (true) {
         redLED = 1;
         if (SW1 == 1) {
@@ -57,13 +45,12 @@
 
 //Main thread
 int main() {
-    redLED    = 0;
-    yellowLED = 0;
-    greenLED  = 0;
-                
+    post();
+                    
     //Main thread ID
     tidMain = Thread::gettid();  
     
+    //Create a thread with normal priority
     Thread t1(osPriorityNormal);
     t1.start(thread1);
     
@@ -73,7 +60,7 @@
     Thread t2(osPriorityAboveNormal);
     t2.start(thread2);
     
-    pc.printf("Main Thread\n");
+    printf("Main Thread\n");
     while (true) {
         Thread::wait(osWaitForever);
     }