参考https://blog.csdn.net/booksyhay/article/details/82696779
通过初始化为0值的信号量,同步两个线程;
1、信号量初始化
osSemaphoreId_t sem;
sem = osSemaphoreNew(1, 0, NULL);
2、线程1
printf("thread 1\r\n");
osSemaphoreRelease(sem);
3、线程2
osSemaphoreAcquire(sem, osWaitForever);
printf("thread 2\r\n");
4、结论
通过0值信号量,同步线程1与线程2,不论调度器是先执行线程1,还是先执行线程2,都是先输出"thread 1";
来源:CSDN
作者:小C菜鸟
链接:https://blog.csdn.net/C_cai_niao/article/details/103928929