
由于自己最近开发记步算法有些问题一直记步十分不准确,先发一个如何使用mbed来使用rtos的帖子。先给一个线程打印实现程序:![]() #include "rtos.h"#include "mbed.h" Serial pc(SERIAL_TX, SERIAL_RX); uint8_t theadindex[2]; //线程打印的数字 long count[2]; void printstr(void const *args) { while (true) { count[*(uint8_t *)args-1]++; Thread::wait(500); } } int main() { theadindex[0]=1; theadindex[1]=2; Thread thread1(printstr,(void *)theadindex,osPriorityNormal); Thread thread2(printstr,(void *)(theadindex+1),osPriorityHigh); while (1) { pc.printf("Thread1 count is %ld,Thread2 count is %ld. \n",count[0],count[1]); Thread::wait(1000); } } ![]() 运行结果如下 ![]() |
多谢分享![]() |
感谢分享!顶一个! |
感谢分享 |
这个问题很好! |
学习一下。 |
不错 |
MBED现在很火啊。 |
貌似很高端的样子 |
不错,谢谢分享@ |
楼主可以把怎么导入RTOS写一下嘛 |