Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 DigitalOut led1(LED6); 00004 DigitalOut led2(LED1); 00005 00006 Mutex mutex; 00007 00008 uint32_t cont =0; 00009 bool done[2] = {0,0}; 00010 00011 Thread t1; 00012 Thread t2; 00013 00014 void thread1( const int *i){ 00015 int conth; 00016 int conth2 =0; 00017 while(conth2<100){ 00018 mutex.lock(); 00019 conth = cont; 00020 conth2++; 00021 conth++; 00022 Thread::wait(10); 00023 cont = conth; 00024 printf(" %d\n\r ",cont); 00025 mutex.unlock(); 00026 } 00027 done[(int)i] =1; 00028 } 00029 00030 00031 int main(){ 00032 t1.start(callback(thread1, (int*) 1)); 00033 t2.start(callback(thread1, (int*) 2)); 00034 while(1){ 00035 Thread::wait(1); 00036 if(done[0] && done[1]){ 00037 if(cont == 200){ 00038 led1=1; 00039 } 00040 else{ 00041 led2 = 1; 00042 } 00043 } 00044 } 00045 } 00046
Generated on Fri Oct 27 2023 22:25:03 by
1.7.2