二值信号量的使用例子Tornado
#include
#include
#include #define STACK_SIZE 0x1000void thisPrint(void);
void thatPrint(void);
SEM_ID sem1Sync;
SEM_ID sem2Sync;
int main()
{
sysClkRateSet(1000);
//二值信号量,初始值不同
sem1Syc = semBCreate(SEM_Q_PRIORITY, 1);
sem2Syc = semBCreate(SEM_Q_PRIORITY, 0);
//多任务
taskSpawn("task1", 100, 0, STACK_SIZE, (FUNCPTR)thatPrint, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
taskSpawn("task1", 100, 0, STACK_SIZE, (FUNCPTR)thatPrint, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
while (1)
{
taskDelay(1);
}
return 0;
}void thisPrint()
{
int thiscout = 0;
while (1)
{
semTake(sem1Sync, WAIT_FOREVER);
for (thiscout= 0;
thiscout < 3;
thiscout++)
{
printf("this->%d\n", thiscout);
taskDelay(1);
}
semGive(sem2Sync);
}
}void thatPrint()
{
int thatcout = 0;
while (1)
{
semTake(sem2Sync, WAIT_FOREVER);
for (thatcout = 0;
thatcout < 5;
thatcout++)
{
printf("that->%d\n", thatcout);
taskDelay(1);
}
semGive(sem1Sync);
}
}
【二值信号量的使用例子Tornado】
推荐阅读
- 《真与假的困惑》???|《真与假的困惑》??? ——致良知是一种伟大的力量
- Shell-Bash变量与运算符
- (二)ES6第一节变量(let|(二)ES6第一节变量(let,const)
- 20210307《挑战赛怂人胆》【能量将帅挑战赛(01)】
- 《离开却带走了“能量的魔杖”(52)》能量爱情公寓
- 私有化轻量级持续集成部署方案--03-部署web服务(下)
- 概率论/统计学|随机变量 的 分布函数 与 概率密度函数 的区别
- 以太坊中的计量单位及相互转换
- 不要和满身负能量的人交朋友
- 爱与恨的力量