Yielding the Control of Execution
Syntax
A thread can yield its execution to other threads. This is done by function
thr_yield():
void thr_yield(void);
- This function does not require any arguments and returns
nothing.
- The function causes the calling thread to yield its execution in
favor of another thread. It is equivalent to say that the calling
thread is put back to the ready queue and a thread from the ready
queue is picked as the candidate for execution. Note that it is
possible that the calling thread is picked if the ready queue
is empty when thr_yield() is called.
- Since the calling thread is temporarily suspended, one may
consider it entering a "sleeping" state for an unspecified
period. In this way, it ``simulates'' sleep().