Open System Services System Calls Reference Manual (G06.25+, H06.03+)

sched_yield(2) OSS System Calls Reference Manual
NAME
sched_yield - Signals a willingness to yield the processor to another thread in the current process
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <sched.h> ]
#include <spthread.h>
int sched_yield(void);
DESCRIPTION
This function forces the calling thread to relinquish its processor until it again becomes the head
of its thread list. This function noties the thread scheduler that the calling thread is willing to
release its processor to other threads of equivalent or greater scheduling precedence. (A thread
generally releases its processor to a thread of a greater scheduling precedence without calling
this function.) If no other threads of equivalent or greater scheduling precedence are ready to
execute, the calling thread continues.
This function can allow you to use knowledge of the details of an application to improve its per-
formance. If a thread does not call sched_yield( ), other threads might be given the opportunity
to run at arbitrary points (possibly even when the interrupted thread holds a required resource).
By making strategic calls to sched_yield( ), other threads can be given the opportunity to run
when the resources are free, which can sometimes improve performance by reducing contention
for resources.
Consider calling this function after a thread has released a resource (such as a mutex) that is
heavily used by other threads. This call can be especially important if the thread acquires and
releases the resource inside a tight loop.
Use this function carefully and sparingly, because misuse can cause unnecessary context switch-
ing, which increases overhead and degrades performance. For example, performance is degraded
if a thread yields while it holds a resource needed by the threads it is yielding to. Likewise,
yielding is pointless unless another thread is ready to run.
RETURN VALUES
Upon successful completion, this function returns a 0 (zero).
RELATED INFORMATION
Functions: pthread_attr_setschedparam(2), pthread_setschedparam(2).
STANDARDS CONFORMANCE
This function is an extension to the XPG4 Version 2 specication. Interfaces documented on this
reference page conform to the following industry standards:
IEEE Std 1003.1c-1995, POSIX System Application Program Interface
The use of the header le spthread.h is an HP exception to the POSIX standard.
74 Hewlett-Packard Company 527186-003