当前位置:网站首页>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.
边栏推荐
- Pod Scheduling Strategy: Affinity, Stain and Stain Tolerance
- According to the field classification Golang map array
- redis cluster cluster, the ultimate solution?
- zabbix automated monitoring script
- 【The 6th Strong Net Cup CTF-Wp】
- SQL Server 数据库之生成与执行 SQL 脚本
- 内存存储结构
- Distributed current limiting, hand & redisson implementation
- 主流跨端技术一览
- SQL function TRIM
猜你喜欢

js炫酷仪表盘插件

JVM学习----垃圾回收调优

Data Lake (2): What is Hudi

excel 批量翻译-excel 批量函数公司翻译大全免费

Pytorch 占用cpu资源过多

darknet训练yolov4模型

Do you really understand the business process service BPass?

Software component analysis: 5 major capabilities to protect software supply chain security

自定义mvc框架复习

An example of type3 voltage loop compensator taking Boost as an example
随机推荐
SQL Server 2014安装教程(保姆级图解教程)
主流跨端技术一览
商业流程服务BPass你真的了解吗?
Transfer files between servers
WPF——自定义日历
How to connect TDengine through DBeaver?
SQL function TRIM
Process finished with exit code 1
手撸架构,网络 面试36问
数据湖(三):Hudi概念术语
package.json与package-lock.json
photo-sphere-viewer中文文档
MD5详解(校验文件完整性)
用位运算为你的程序加速
力扣704-二分查找
Hand rolled architecture, 41 Redis interview asked
ABAP-OOAVL模板程序
redis cluster cluster, the ultimate solution?
Process finished with exit code 1
如何搭建威纶通触摸屏与S7-200smart之间无线PPI通信?