rtos2

Dependencies:   mbed-rtos mbed

Fork of rtos_2 by Xisco Sastre Cabot

main.cpp

Committer:
xiscosc
Date:
2015-11-13
Revision:
7:14841d8f93e4
Parent:
3:c92e21f305d8

File content as of revision 7:14841d8f93e4:

#include "mbed.h"
#include "rtos.h"
DigitalOut led1(LED1);
DigitalOut led2(LED2);
double status; 
Timer t; 
bool b;

void thread1(void const *args) {
    while (true) {
            t.stop();  
            if (b) {
                printf("The time taken was %f seconds \r\n", t.read());
                b = false;
            }
            t.reset();
            led1 = !led1;
            for(double i=0; i<100000; i++) {
                   status = i;  
                }
            led1 = !led1;
            Thread::wait(300);
        }
    }


int main() {
    led1 = false;
    led2 = false;
    b = true;
    osThreadSetPriority(osThreadGetId(),osPriorityHigh);
    Thread my_thread1(thread1, NULL, osPriorityHigh);
    while (true) {
            t.reset();
            t.start();
            led2 = !led2;
            for(double i=0; i<100000; i++) {
                   status = i;  
                }
            led2 = !led2;
            Thread::wait(300);
        }
}