📄 testostaskidget.c
字号:
#include "taskTest.h"
int testOSTaskIdGet()
{
OS_STATUS status;
unsigned32 Task_id1,Task_id2,Task_id3,Task_id4;
printf("*** test of OSTaskIdGet ***\n");
printf("create three tasks\n");
status = OSTaskCreate("tsk1",101,STACK_MINIMUM_SIZE,OS_DEFAULT,OS_DEFAULT,&Task_id1);
if(status != OS_OK)
{
printf("OSTaskCreate error:[%s]\n",serrno(errno));
return (-1);
}
printf("the id of task1 is %d\n",Task_id1);
status = OSTaskCreate("tsk2",101,STACK_MINIMUM_SIZE,OS_DEFAULT,OS_DEFAULT,&Task_id2);
if(status != OS_OK)
{
printf("OSTaskCreate error:[%s]\n",serrno(errno));
return (-1);
}
printf("the id of task2 is %d\n",Task_id2);
status = OSTaskCreate("tsk3",101,STACK_MINIMUM_SIZE,OS_DEFAULT,OS_DEFAULT,&Task_id3);
if(status != OS_OK)
{
printf("OSTaskCreate error:[%s]\n",serrno(errno));
return (-1);
}
printf("the id of task3 is %d\n",Task_id3);
printf("get the id of task1...\n");
status = OSTaskIdGet ("tsk1",0,&Task_id4);
if(status != OS_OK)
{
printf("OSTaskIdGet error:[%s]\n",serrno(errno));
return (-1);
}
else
{
if (Task_id1 == Task_id4)
printf("the id of task1 got by OSTaskIdGet is right![%d]\n",Task_id4);
else
{
printf("the id of task1 got by OSTaskIdGet is wrong![%d]\n",Task_id4);
return -1;
}
}
printf("get the id of task2...\n");
status = OSTaskIdGet ("tsk2",0,&Task_id4);
if(status != OS_OK)
{
printf("OSTaskIdGet error:[%s]\n",serrno(errno));
return (-1);
}
else
{
if (Task_id2 == Task_id4)
printf("the id of task2 got by OSTaskIdGet is right![%d]\n",Task_id4);
else
{
printf("the id of task2 got by OSTaskIdGet is wrong![%d]\n",Task_id4);
return -1;
}
}
printf("get the id of task3...\n");
status = OSTaskIdGet ("tsk3",0,&Task_id4);
if(status != OS_OK)
{
printf("OSTaskIdGet error:[%s]\n",serrno(errno));
return (-1);
}
else
{
if (Task_id3 == Task_id4)
printf("the id of task3 got by OSTaskIdGet is right![%d]\n",Task_id4);
else
{
printf("the id of task3 got by OSTaskIdGet is wrong![%d]\n",Task_id4);
return -1;
}
}
OSTaskDelete(Task_id1);
OSTaskDelete(Task_id2);
OSTaskDelete(Task_id3);
printf("*** OSTaskIdGet test OK! ***\n\n");
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -