Some operating systems use an idle thread
to handle
cases in which the ready queue
would otherwise become
empty. Instead of handling those cases individually, the idle
thread
simply gets scheduled. The idle thread
,
with some infamous exceptions, then puts the machine in a low-power
state until an event (e.g. interrupt) enables another thread to
run.
The didactic version of OpenEPOS you are currently working with
implements the idle
thread as a function that is called
whenever there is no other thread on the ready
queue to
run, like in the excerpt of the suspend()
method
reproduced bellow:
1.
|
if(!_ready.empty())
|
The idle()
function is shown bellow:
1.
|
void Thread::idle()
|
Modify the implementation of idle
so it becomes a
thread that is only scheduled when there are no other threads ready
to run. This will eliminate bugs such as having the
timer
handler undesirably waking up suspended
threads.