[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


sched_yield

Yields execution to another thread (P1003.1b).

Syntax

sched_yield();

C Binding

#include 
#include 

int sched_yield ( void);

Arguments

None

Description

The sched_yield function yields execution to another thread. It is useful when an application running under the SCHED_FIFO scheduling policy needs to allow another thread at the same priority to run. The thread that was interrupted by sched_yield goes to the end of the queue for its priority. The sched_yield function takes no arguments.

If no other thread is runnable at the priority of the caller, the caller continues to run.

Threads with higher priority are allowed to preempt the running thread, so the sched_yield function has no effect on the scheduling of higher- or lower-priority threads.

No special privileges are needed to use the sched_yield function.

Return Values

If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
Return        Description

0 Successful completion. -1 Unsuccessful completion - errno is set to indicate that an error occurred. [ENOSYS] The function sched_yield is not supported by this implementation.


Associated Routines

   pthread_attr_setschedparam
   pthread_setschedparam
   pthread_getscheduler
   pthread_setscheduler



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]