no kind of duty
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "rtos.h" 00002 #include "mbed.h" 00003 Serial pc(SERIAL_TX, SERIAL_RX); 00004 00005 uint8_t theadindex[2]; 00006 00007 long count[2]; 00008 00009 void printstr(void const *args) 00010 00011 { 00012 00013 while (true) { 00014 00015 count[*(uint8_t *)args-1]++; 00016 00017 Thread::wait(500); 00018 00019 } 00020 00021 } 00022 00023 int main() 00024 00025 { 00026 00027 theadindex[0]=1; 00028 00029 theadindex[1]=2; 00030 00031 Thread thread1(printstr,(void *)theadindex,osPriorityNormal); 00032 00033 Thread thread2(printstr,(void *)(theadindex+1),osPriorityHigh); 00034 00035 while (1) 00036 00037 { 00038 00039 pc.printf("Thread1 count is %ld,Thread2 count is %ld. \n",count[0],count[1]); 00040 00041 Thread::wait(1000); 00042 00043 } 00044 00045 }
Generated on Tue Jul 12 2022 17:28:34 by
1.7.2