当前位置:网站首页>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.
边栏推荐
猜你喜欢

NVIDIA NeMo Metrics 轻量性能采集系统

OpenFeign设置header的3种方式

Pytorch 占用cpu资源过多

Taurus.MVC V3.0.3 Microservice Open Source Framework Released: Make the evolution of .NET architecture easier in large concurrency.

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

1.3快速生成树协议RSTP

如何搭建威纶通触摸屏与S7-200smart之间无线PPI通信?

SQL Server 数据库之导入导出数据

Likou 35 - search for insertion position - binary search

Import and export data of SQL Server database
随机推荐
Chapter 14 Manually create a REST service (2)
Lexicon 27 - Remove Elements - Simple Questions
SuperSlide系列之轮播图
MD5 detailed explanation (check file integrity)
7种最常用数据分析思维,解决95%的分析难题
商业流程服务BPass你真的了解吗?
项目监控六大事项
力扣704-二分查找
Software component analysis: 5 major capabilities to protect software supply chain security
数据湖(二):什么是Hudi
今日睡眠质量记录85分
Learning Experience Sharing Seven: YOLOv5 Code Chinese Comments
力扣209-长度最小的字符串——滑动窗口法
Leek 151 - Reverse words in a string
【MySQL系列】- LIKE查询 以%开头一定会让索引失效吗
Likou 704 - binary search
SQL Server 数据库之生成与执行 SQL 脚本
Speed up your programs with bitwise operations
AQS-AbstractQueuedSynchronizer
SQL Server 数据库之导入导出数据