当前位置:网站首页>物联网操作系统多任务基础
物联网操作系统多任务基础
2022-07-27 05:19:00 【an0420】
物联网操作系统多任务基础
周末休息回来继续学习!
一.多任务基础
1.多任务特性
任务调度机制
1.时间片调度机制
核心为时间片的轮询,同优先级只能通过时间片轮询的调度。
2.抢占调度机制
当任务优先级不一致,低优先级挂起,高优先级先执行,中断(isr)产生优先级最高。
3.任务特性
1.编程简单
2.任务数量没有限制。
3.支持抢占。
4.优先级排序。
5.独立的堆栈。任务切换时需要切换CPU的运行环境。(所以操作系统的特性)
4.任务的状态
任务一共有四种状态:
1.挂起态:任务在挂起状态时,将不会被调度器所调度。
2.就绪态:任务将运行时等待任务调度的状态。
3.阻塞态:osDelay,给任务一个延时,使他阻塞,然后等待调度器的调度。
4.运行态:
5.任务优先级

2.多任务实现
每个任务都是由3部分实现
(1)死循环
(2)任务实体
(3)任务退出:无返回值。
void freertosTask(void const * argument){
for(;;){
osDelay();
}
}
任务控制块
任务控制块是描述任务属性的结构体。
三、任务堆栈

二、任务创建
1.创建任务
(1)任务创建API
xTaskCreate();//动态创建任务 使用时 configSUPPORT_DYNAMIC_ALLOCATION必须置1
xTaskCreateStatic(); 使用时 ConfigSUPPORT_STATIC_ALLICATION置1.
(2)使用cubemax在任务中1s打印一次任务运行标志
复制上篇工程,使能串口配置为异步通信,打开FreeRTos在配置选项一栏选择内存配置,配置为动态静态混用。
配置完成之后创建串口任务,生成keil文件。
工程如下
(3)使用按键控制Led任务挂起和恢复
void vTaskSuspend( TaskHandle_t pxTaskToSuspend ); // 挂起
void vTaskResume( TaskHandle_t pxTaskToResume ); //恢复
源码:https://download.csdn.net/download/ay1204/86261003
注:源码注释下篇
边栏推荐
- 7.合并与分割
- cycleGAN解析
- 贪心高性能神经网络与AI芯片应用研修
- Day10. Work organization and mental health problems in PhD students
- 【头歌】重生之我在py入门实训中(9):异常处理
- 基于深度神经网络的社交媒体用户级心理压力检测
- 服务器相关的指标解释
- Public opinion & spatio-temporal analysis of infectious diseases literature reading notes
- 古老的艺术-用好长尾关键词
- Emoji Emoji for text emotion analysis -improving sentimental analysis accuracy with Emoji embedding
猜你喜欢

5.索引和切片

西瓜书学习第五章---神经网络

Day 3. Suicidal ideation and behavior in institutions of higher learning: A latent class analysis

为什么交叉熵损失可以用于刻画损失

2. Simple regression problem

韦东山 数码相框 项目学习(四)简易的TXT文档显示器(电纸书)

Day 7. Towards Preemptive Detection of Depression and Anxiety in Twitter
![[MySQL learning] 8](/img/25/84d5acbdd8aba3455ab8e3eb17dfa8.png)
[MySQL learning] 8

Day 9. Graduate survey: A love–hurt relationship

【头歌】重生之机器学习-线性回归
随机推荐
Unittest套件与运行器
Day 3. Suicidal ideation and behavior in institutions of higher learning: A latent class analysis
Emoji表情符号用于文本情感分析-Improving sentiment analysis accuracy with emoji embedding
数字图像处理——第九章 形态学图像处理
视觉横向课题bug1:FileNotFoundError: Could not find module ‘MvCameraControl.dll‘ (or one of it
Performance optimization of common ADB commands
Digital image processing -- Chapter 9 morphological image processing
李宏毅 2020 深度学习与人类语言处理 DLHLP-Conditional Generation by RNN and Attention-p22
[MVC Architecture] MVC model
9.高阶操作
小技巧-彻底删除U盘中的文件
pytorch使用data_prefetcher提升数据读取速度
Day 9. Graduate survey: A love–hurt relationship
14.实例-多分类问题
14. Example - Multi classification problem
代码随想录笔记_哈希_242有效的字母异位词
Day 17.The role of news sentiment in oil futures returns and volatility forecasting
Gbase 8C - SQL reference 4 character set support
模型的推理速度
Uboot supports LCD and HDMI to display different logo images