This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RTOS : Task switch during a time tick

Dear all,

I have to work with RL-RTX, and I have first look at the RTX traffic example. There is something I do not understand about task switching. Some years ago, I was working on a home-made RTOS, and the switch from a task to another could only occured at "kernel time" (that means at every time tick). If a task only used 50% of a tick time, the rest of the tick time was for "idle", and next task only starts after the kernel time at the end of the tick.
With the traffic example, it seems that when a task is delayed (by instance with os_dly_wait) during a tick time, another "ready" task can directly start, without waiting for the end of the tick time when the kernel will run.
Is it right? If yes, can you explain me how it works? (maybe the kernel runs to switch the tasks even if the time tick is not finished?)
Thanks !
Best regards

Parents
  • An RTOS is designed with the RT very much in mind, i.e. Real Time.

    So it normally allows a switch whenever a reason is found. Which may be that a task says: "I'm done". Or that the task sends a message that a higher-prio task has been waiting for. Or that an interrupt receives some data and makes this data available to some task.

    It is also common that the OS runs an internal clock at a higher speed than the normal time slices. If each slice is 10 clock ticks and one thread doesn't consume the full 10 ticks but gets ended after only 8 ticks, then the next thread can still start a full 10-tick slice instead of getting punished by getting only two ticks, i.e. the remainder of the slice time donated by the previous thread.

    So a good RTOS is not ticking forward like it would be playing sheet music, but is trying to instantly switch when an event makes a more prioritized thread runnable. This gives lower latencies when responding to events - i.e. "real time".

Reply
  • An RTOS is designed with the RT very much in mind, i.e. Real Time.

    So it normally allows a switch whenever a reason is found. Which may be that a task says: "I'm done". Or that the task sends a message that a higher-prio task has been waiting for. Or that an interrupt receives some data and makes this data available to some task.

    It is also common that the OS runs an internal clock at a higher speed than the normal time slices. If each slice is 10 clock ticks and one thread doesn't consume the full 10 ticks but gets ended after only 8 ticks, then the next thread can still start a full 10-tick slice instead of getting punished by getting only two ticks, i.e. the remainder of the slice time donated by the previous thread.

    So a good RTOS is not ticking forward like it would be playing sheet music, but is trying to instantly switch when an event makes a more prioritized thread runnable. This gives lower latencies when responding to events - i.e. "real time".

Children