thread

Dependencies:   mbed-rtos-old mbed

Committer:
mbedschool
Date:
Sat Feb 14 04:36:12 2015 +0000
Revision:
1:f7560a90fe56
Parent:
0:3d53a9e8fc73
thread

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedschool 0:3d53a9e8fc73 1 #include "mbed.h"
mbedschool 0:3d53a9e8fc73 2 #include "rtos.h"
mbedschool 0:3d53a9e8fc73 3
mbedschool 0:3d53a9e8fc73 4 DigitalOut myled(LED1);
mbedschool 0:3d53a9e8fc73 5 bool c=false;
mbedschool 0:3d53a9e8fc73 6 void led1_thread(void const *argument) {
mbedschool 0:3d53a9e8fc73 7
mbedschool 0:3d53a9e8fc73 8 while (!c) {
mbedschool 0:3d53a9e8fc73 9 myled = !myled;
mbedschool 0:3d53a9e8fc73 10 Thread::wait(200);
mbedschool 0:3d53a9e8fc73 11 }
mbedschool 0:3d53a9e8fc73 12 myled=1;
mbedschool 0:3d53a9e8fc73 13 }
mbedschool 0:3d53a9e8fc73 14 int main() {
mbedschool 0:3d53a9e8fc73 15
mbedschool 0:3d53a9e8fc73 16 Thread th1(led1_thread);
mbedschool 0:3d53a9e8fc73 17 while(1) {
mbedschool 0:3d53a9e8fc73 18 unsigned long n=100000000;
mbedschool 0:3d53a9e8fc73 19 float x=0;
mbedschool 0:3d53a9e8fc73 20 while(x*x <n)
mbedschool 0:3d53a9e8fc73 21 x = x + 0.01 ;
mbedschool 0:3d53a9e8fc73 22 c=true;
mbedschool 0:3d53a9e8fc73 23 }
mbedschool 0:3d53a9e8fc73 24
mbedschool 0:3d53a9e8fc73 25 }