-1

Assuming a single thread, what keeps the task from just running until completion in the round robin algorithm?

Is there some sort of watchdog mechanism to keep this from happening?

J. Stone
  • 1
  • 1

1 Answers1

0

In a cooperative scheduling system, nothing. A task generally has to call some OS function (either an explicit yield or something else that may implicitly yield, like a message get function).

In a pre-emptive scheduling system, they are pre-empted (obviously) by the OS, the state is saved, and the next task is restored and run.

For example, Linux has a 100ms (from memory) quanta that it gives to each thread. The thread can relinquish its quanta early (and it's often treated nicely if it does so) but, if it uses its entire quanta, it's forcefully paused by the OS.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953