The didactic version of OpenEPOS you are currently working with implements thread joining with a simple trick: yielding other threads to run.
1.
|
int Thread::join()
|
That is, a joining thread checks the state of the thread being
waited for until it turns to FINISHING
. In order to
give other threads a chance to run, and thus terminate, the calling
thread invokes yield
on each step.
Line 4, which is not in the scope of this exercise, simply forwards the value left on the stack by the terminating thread to the waiting thread.
Change the implementation of Thread
so that
join()
no longer wastes time sampling the waited thread
status. It must be set to sleep until the waited-for thread
terminates, and then waken up accordingly.