当前位置:网站首页>1281_FreeRTOS_vTaskDelayUntil实现分析
1281_FreeRTOS_vTaskDelayUntil实现分析
2022-06-25 21:50:00 【grey_csdn】
全部学习汇总: GreyZhang/g_FreeRTOS: learning notes about FreeRTOS. (github.com)
前面简单分析了vTaskDelay(),这一次分析一下vTaskDelayUntil()的实现。之前,看文档的时候模模糊糊记得vTaskDelayUntil()能够完成的延迟更加精准一些。这一次,从代码设计的角度来看看为什么。

这里的pxPreviousWakeTime实现的功能还是一个参数的传入功能,传入的是一个时间基准。当然,它本身是一个指针,传入的并不是一个数值参数。这里,关键的一点信息在于:1,调度器不能挂起; 2,唤醒时间定时设置。看上去,套路跟之前分析的vTaskDelay()没有太大的差异。

这里,区分了tick是否超时。在每一种情况下,都判断了延时时间是否已经达到。如果达到了,那么接下来直接请求任务调度即可。

其实,这部分的处理跟之前分析的vTaskDelay()的处理接口也是很相似的。其实,主要的方式就是加入到delayed task链表之后触发任务调度请求。
那么,这两个接口差异点究竟在哪里呢?为什么说vTaskDelay()不如vTaskDelayUntil()精准呢?其实,看完代码基本上也能够理解两者的差异。如果理解两者的差异,其实从函数的接口形式就能够看出一些端倪。两个接口的延时实现其实都是定时器设置一个参考值之后不断进行判断,但是这个参考点的设置是不同的。vTaskDelay()设置的参考点总是从当前开始,而vTaskDelayUntil()参考点的设置其实是可以指定的。

这是一个使用的代码例子,其实,我觉得这个例子实现的功能跟vTaskDelay()接口实现的功能也没有太大的差异。尤其是出现 某些高优先级任务抢占的时候。那么,如果才会让着两个接口实现有一定差异呢?那肯定是参考点的设置不断更新的时候,可能会存在更加灵活的方式。

这是针对例子的分析以及增加的一个对比。其实,不管是vTaskDelayUntil()还是vTaskDelay(),如果不断遭遇到运行时间久且优先级高的任务,本身的精准度肯定都会受到影响。毕竟到现在为止,并没有看到这样的任务优先级有提升。从这个角度讲,前面考虑到的差异点,其实2种接口都受到影响。排除这样的差异之后,这两个接口的差异可以理解为:vTaskDelay()设置的其实是时间等待,而vTaskDelayUntil()实现的是框定一个时间窗口。
边栏推荐
- Use of local stack in flask
- 2022 love analysis · panoramic report of it operation and maintenance manufacturers
- The difference between synchronize and volatile
- How to disable the optical drive
- ES6-- 模板字符串、对象的简化写法、箭头函数
- Global and Chinese flame retardant ABS industry development trend and market demand analysis report 2022 ~ 2028
- Analysis report on market demand situation and investment direction of China's optical transmission equipment industry from 2022 to 2028
- How to guarantee idempotency of message queue
- Why can't the mobile phone be used and the computer be connected
- GStreamer initialization and plugin registry procedures
猜你喜欢

2022-2028 global horizontal reciprocating compressor industry research and trend analysis report
![[WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF](/img/50/bb9e73cb4eabcef4bee8f6d5b2fcb6.png)
[WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF

Zhihu Gaozan: what ability is important, but most people don't have it?

再突破!阿里云进入Gartner云AI开发者服务挑战者象限

Summary of basic knowledge of neural network

2022-2028 global proton exchange membrane hydrogen electrolyzer industry survey and trend analysis report

2022-2028 global DC linear variable differential transformer (LVDT) industry survey and trend analysis report
To ensure the Beijing Winter Olympic Games, digital data gives a power without code!

CVPR2022教程 | 马里兰大学《机器学习遥感处理:农业与粮食安全》教程

2022-2028 global industrial touch screen industry research and trend analysis report
随机推荐
APP-新功能上线
Factorymethod factory method
2022-2028 global industrial touch screen industry research and trend analysis report
Research and Analysis on the current situation of Chinese acne drug market and forecast report on its development prospect (2022)
Client cannot authenticate via:[TOKEN, KERBEROS]
Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
adb常用命令
2022-2028 global RBI platform industry research and trend analysis report
民航局:到 2025 年我国将初步建成安全、智慧、高效和绿色的航空物流体系
What is 5g? What can 5g do? What will 5g bring in the future?
Analysis report on market business model and development direction of China mobile operation industry from 2022 to 2028
Ribbon core ⼼ source code analysis
China soft magnetic material market demand status and prospect scale forecast report 2022-2028
Lecture 14 of the Blue Bridge Cup -- number theory [exercises]
Unity技术手册 - 生命周期旋转RotationOverLifetime-速度旋转RotationBySpeed-及外力
2022-2028 global extrusion coating and lamination production line industry research and trend analysis report
Analysis report on market demand situation and investment direction of China's optical transmission equipment industry from 2022 to 2028
Tlog helps Pangu framework realize microservice link log tracking
Record the learning record of the exists keyword once
Interview shock 23: talk about thread life cycle and transformation process?