sched_yieldのヘルプ・マニュアル
日本語 英語
sched_yield --help
man sched_yield
SCHED_YIELD(2) Linux Programmer’s Manual SCHED_YIELD(2)
名前
sched_yield - プロセッサーを空け渡す(yield)
書式
#include
int sched_yield(void);
説明
sched_yield() を呼び出すことで、呼び出したスレッドが CPU の使用権を手放
すことができる。そのスレッドは、そのスレッドの静的プライオリティのキ ュ
ーの末尾に移動し、新しいスレッドが走り始める。
返り値
成 功した場合は sched_yield() は 0 を返す。エラーの場合は -1 が返され、
errno が適切に設定される。
エラー
Linux の実装では、 sched_yield() は常に成功する。
準拠
POSIX.1-2001.
注意
sched_yield() を呼び出した時点で最大優先度のリストの中に呼び出し元の ス
レ ッドしか存在しなければ、そのスレッドは呼び出し後も走り続けることにな
る。
POSIX シス テ ム で sched_yield() は に _POSIX_PRIOR-
ITY_SCHEDULING が定義されている場合にのみ使用可能である。
sched_yield() を 戦 略 的 に呼び出すことで、(極度に) 競合するリソース
(mutex など) を呼び出し元が解放した際に他のスレッドやプロセスに実行機会
を与えることで、性能を上げることができる。 sched_yield() を必要もないの
に呼び出したり、不適切な場面 (例えば、他のスケジューリング対象となる ス
レ ッドが必要とするリソースを呼び出し元が保持したままの状態) で呼び出し
たりするのは避けること。なぜなら、 sched_yield() の呼び出しより不必要な
コ ンテキストスイッチが起こり、システム性能が劣化する結果になるからであ
る。
関連項目
Linux のスケージュリング(scheduling)については sched_setscheduler(2) を
参照せよ。
Programming for the real world - POSIX.4 by Bill O. Gallmeister,
O’Reilly & Associates, Inc., ISBN 1-56592-074-0
Linux 2008-10-18 SCHED_YIELD(2)
SCHED_YIELD(2) Linux Programmer’s Manual SCHED_YIELD(2)
NAME
sched_yield - yield the processor
SYNOPSIS
#include
int sched_yield(void);
DESCRIPTION
sched_yield() causes the calling thread to relinquish the CPU. The
thread is moved to the end of the queue for its static priority and a
new thread gets to run.
RETURN VALUE
On success, sched_yield() returns 0. On error, -1 is returned, and
errno is set appropriately.
ERRORS
In the Linux implementation, sched_yield() always succeeds.
CONFORMING TO
POSIX.1-2001.
NOTES
If the calling thread is the only thread in the highest priority list
at that time, it will continue to run after a call to sched_yield().
POSIX systems on which sched_yield() is available define _POSIX_PRIOR-
ITY_SCHEDULING in .
Strategic calls to sched_yield() can improve performance by giving
other threads or processes a chance to run when (heavily) contended
resources (e.g., mutexes) have been released by the caller. Avoid
calling sched_yield() unnecessarily or inappropriately (e.g., when
resources needed by other schedulable threads are still held by the
caller), since doing so will result in unnecessary context switches,
which will degrade system performance.
SEE ALSO
sched_setscheduler(2) for a description of Linux scheduling.
Programming for the real world - POSIX.4 by Bill O. Gallmeister,
O’Reilly & Associates, Inc., ISBN 1-56592-074-0
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2008-10-18 SCHED_YIELD(2)