3

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. 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.

If the task last longer than 0.5 ms, OS scheduler will preempt my high-priority thread to give time to my low-priority. 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?

Aconcagua
  • 24,880
  • 4
  • 34
  • 59
c.censier
  • 781
  • 7
  • 23
  • If the thread is preempted it will put into waiting for reschedule, what do you mean "can be warned", you want it to receive a signal or something? – fluter May 02 '16 at 07:23
  • First I want to know if it's even possible. Any mechanism would be nice, "signal or something". – c.censier May 02 '16 at 07:27
  • It does not make sense because at the time the thread's cpu time is off, it will not be on any cpu to run, not to say processing signal. – fluter May 02 '16 at 07:29
  • The thread won't get the signal or whatever else at end of processing time - but possibly it is OK to receive the information after the thread resumes? – Aconcagua May 02 '16 at 07:32
  • 2
    But maybe when the thread is resumed ? In real-time environnement, it's problematic when a thread could not finish its job. When it wake up, the non-finished task may doesn't have sens anymore. – c.censier May 02 '16 at 07:33

1 Answers1

3

Currently, the SCHED_DEADLINE API doesn't provide the feature needed for signaling the task that it has been throttled. 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. See here.

Claudio
  • 10,614
  • 4
  • 31
  • 71