当前位置:网站首页>FreeRTOS experiment--one function creates multiple tasks
FreeRTOS experiment--one function creates multiple tasks
2022-08-02 12:31:00 【Mountain,】
之前说过,创建任务的时候,Can be passed to task parameters,下面通过实验,Passing different parameters to a task function shows how to create multiple tasks with one function.
任务函数:Convert incoming data to inttype data and then print it out.
void TaskAll(void * param)
{
int val = (int)param;
while(1)
{
printf("%d",val);
}
}
主函数:使用TaskAllThe function creates three tasks,Each task passes in different parameters,Except the incoming parameters are different,其他的参数都一样,In fact, even the incoming parameters can be the same,But to make the phenomenon more obvious,Different parameters are passed in here.
int main( void )
{
prvSetupHardware();
printf("Hello World!\r\n");
xTaskCreate(TaskAll,"TaskAll",100,(void*)1,1,NULL);
xTaskCreate(TaskAll,"TaskAll",100,(void*)2,1,NULL);
xTaskCreate(TaskAll,"TaskAll",100,(void*)3,1,NULL);
vTaskStartScheduler();
return 0;
}
输出结果:
可以看到,A total of three tasks are executed.
So why use one function to create multiple tasks?
Thought each task was different,Each task has its own stack space,They do not interfere with each other,It's just that the execution function of each of their tasks is the same,All convert parameters to inttype and print out.
由此我们可以明白,任务是任务,函数是函数.The tasks are different from each other,Even if the name of the task is the same,But the name of the task doesn't matter,Because they have their own independent stack space,So they are different tasks.And the function can be the same,the same function name,represents a function,It's just that this function can be used by multiple tasks.
边栏推荐
猜你喜欢
随机推荐
手撸架构,MongDB 面试50问
项目监控六大事项
zabbix自动化监控脚本
NVIDIA NeMo Metrics 轻量性能采集系统
excel 批量翻译-excel 批量函数公司翻译大全免费
阿苹的思考
redis cluster cluster, the ultimate solution?
【MySQL系列】- LIKE查询 以%开头一定会让索引失效吗
ABAP-OOAVL template program
自定义mvc框架复习
技术分享| 融合调度系统中的电子围栏功能说明
Leek 151 - Reverse words in a string
Seneor Exposure Basics
QAbstractScrollArea、QScrollArea
Basic protocol explanation
MD5详解(校验文件完整性)
测试开发之路,我在大厂做测试这四年的感悟
不错的射击类js小游戏源码
SQL Server 数据库之导入导出数据
Likou 35 - search for insertion position - binary search









