简体   繁体   English

检测截止日期线程抢占

[英]Detect deadline thread preemption

I'm implementing a thread using SCHED_DEADLINE scheduling policy which is my high-priority thread and another one using SCHED_FIFO policy which is my low-priority one. 我正在使用SCHED_DEADLINE调度策略来实现一个线程,这是我的高优先级线程,而另一个正在使用SCHED_FIFO策略来实现,这是我的低优先级线程。 As an example, I've defined my deadline thread as follow : 例如,我定义了我的截止日期线程如下:

attr.sched_runtime = 0.5 * 1000000;   // --> 0.5 ms
attr.sched_deadline = 0.6 * 1000000;  // --> 0.6 ms
attr.sched_period = 1 * 1000000;      // --> 1 ms

In a normal behavior, my high-priority thread shouldn't process more than 0.5 ms and while this duration it should have the time to finish its task. 在正常情况下,我的高优先级线程处理的时间不应超过0.5毫秒,而在此持续时间内,它应该有时间完成任务。

If the task last longer than 0.5 ms, OS scheduler will preempt my high-priority thread to give time to my low-priority. 如果任务的持续时间超过0.5毫秒,则OS调度程序将抢占我的高优先级线程以给我的低优先级时间。 This is a behavior I've tested before. 这是我之前测试过的行为。

My question is : how can my high priority thread be warned that it has been preempted by the system? 我的问题是:如何警告我的高优先级线程它已被系统抢占?

Currently, the SCHED_DEADLINE API doesn't provide the feature needed for signaling the task that it has been throttled. 当前,SCHED_DEADLINE API不提供向任务发信号通知它已被限制所需的功能。 We understand that it could be a useful feature, and we will consider it for inclusion in the very next future. 我们了解到它可能是一个有用的功能,因此我们将考虑在不久的将来将其包含在内。

The only option at the moment is to check the time for understanding if a throttling occurred. 目前唯一的选择是检查时间以了解是否发生了节流。

Update : the Linux kernel 4.16 will add support for the "runtime overrun" signaling on SCHED_DEADLINE. 更新 :Linux内核4.16将在SCHED_DEADLINE上添加对“运行时溢出”信号的支持。 See here . 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM