Multithreaded Programming Guide

Yielding Thread Execution

Use sched_yield(3RT) to cause the current thread to yield its execution in favor of another thread with the same or greater priority. If no such threads are ready to run, the calling thread continues to run. The sched_yield() function is not part of the Pthread API, but is a function in the Realtime Library Functions. You must include <sched.h> to use sched_yield().

sched_yield Syntax

int  sched_yield(void);
#include <sched.h>
int ret;
ret = sched_yield();

sched_yield Return Values

sched_yield() returns zero after completing successfully. Otherwise, -1 is returned and errno is set to indicate the error condition.