Yield to other ready threads at the same priority


#include <threads.h>

void thrd_yield( void );



Use the -l c option to qcc to link against this library. This library is usually included automatically.


The thrd_yield() function checks to see if other threads, at the same priority as that of the calling thread, are READY to run. If so, the calling thread yields to them and places itself at the end of the READY thread queue. The thrd_yield() function never yields to a lower-priority thread.

A higher-priority thread always forces a lower-priority thread to yield (that is, preempt) the instant the higher-priority thread becomes ready to run, without the need for the lower-priority thread to give up the processor by calling the thrd_yield(), sched_yield(), or SchedYield() functions.

Note: You should avoid designing programs that contain busy wait loops. If you can't avoid them, you can use thrd_yield() to reduce the scheduling latency for other threads at a given priority level. Note that a thread that calls thrd_yield() in a tight loop will spend a great deal of time in the kernel, which will have a small effect on interrupt latency.



Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes