当前位置:网站首页>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);
}
}
主函数:使用TaskAll
The 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.
边栏推荐
猜你喜欢
LeetCode_139_单词拆分
NVIDIA NeMo Metrics 轻量性能采集系统
Data Lake (2): What is Hudi
SQL Server 数据库之生成与执行 SQL 脚本
Lexicon 27 - Remove Elements - Simple Questions
测试开发之路,我在大厂做测试这四年的感悟
After Effects 教程,如何在 After Effects 中对蒙版进行动画绘制?
Likou 977-Squaring of ordered arrays - brute force method & double pointer method
LeetCode_377_组合总和Ⅳ
simulink PID auto-tuning
随机推荐
svg气球升起爆炸js特效
【MySQL系列】- LIKE查询 以%开头一定会让索引失效吗
免费的中英文翻译软件-自动批量中英文翻译软件推荐大全
第十四章 手动创建 REST 服务(二)
SQL function $TRANSLATE
数据湖(二):什么是Hudi
pytorch模型转tensorflow模型
photo-sphere-viewer中文文档
According to the field classification Golang map array
云原生(三十) | Kubernetes篇之应用商店-Helm介绍
力扣704-二分查找
内存存储结构
PHP伪协议详解
今日睡眠质量记录85分
Learning Experience Sharing Seven: YOLOv5 Code Chinese Comments
不错的射击类js小游戏源码
Likou 35 - search for insertion position - binary search
数据湖(三):Hudi概念术语
MyCat2的介绍与安装以及基本使用
SQL Server 2019安装错误0x80004005 服务没有及时响应启动或控制请求详细解决方法