.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (C) Tom Bjorkholm & Markus Kuhn, 1996 .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, .\" USA. .\" .\" 1996-04-01 Tom Bjorkholm .\" First version written .\" 1996-04-10 Markus Kuhn .\" revision .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated Sun Feb 23 22:42:36 JST 1997 .\" by HANATAKA Shinya .\" Updated 2008-11-10, Akihiro MOTOKI , LDP v3.13 .\" .\"WORD: yield 空け渡す .\"WORD: block 中断(block) .\"WORD: process プロセス .\"WORD: processor プロセッサー .\"WORD: queue キュー .\"WORD: static 静的 .\"WORD: priority プライオリティ .\"WORD: scheduling スケジューリング .\" .TH SCHED_YIELD 2 2008-10-18 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O sched_yield \- yield the processor sched_yield \- プロセッサーを空け渡す(yield) .\"O .SH SYNOPSIS .SH 書式 .B #include .sp .B int sched_yield(void); .\"O .SH DESCRIPTION .SH 説明 .\"O .BR sched_yield () .\"O causes the calling thread to relinquish the CPU. .BR sched_yield () を呼び出すことで、呼び出したスレッドが CPU の使用権を手放すことができる。 .\"O The thread is moved to the end of the queue for its static .\"O priority and a new thread gets to run. そのスレッドは、そのスレッドの静的プライオリティのキューの末尾に 移動し、新しいスレッドが走り始める。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O On success, .\"O .BR sched_yield () .\"O returns 0. .\"O On error, \-1 is returned, and .\"O .I errno .\"O is set appropriately. 成功した場合は .BR sched_yield () は 0 を返す。 エラーの場合は \-1 が返され、 .I errno が適切に設定される。 .\"O .SH ERRORS .SH エラー .\"O In the Linux implementation, .\"O .BR sched_yield () .\"O always succeeds. Linux の実装では、 .BR sched_yield () は常に成功する。 .\"O .SH "CONFORMING TO" .SH 準拠 POSIX.1-2001. .\"O .SH NOTES .SH 注意 .\"O If the calling thread is the only thread in the highest .\"O priority list at that time, .\"O it will continue to run after a call to .\"O .BR sched_yield (). .BR sched_yield () を呼び出した時点で最大優先度のリストの中に呼び出し元のスレッドしか 存在しなければ、そのスレッドは呼び出し後も走り続けることになる。 .\"O POSIX systems on which .\"O .BR sched_yield () .\"O is available define .\"O .B _POSIX_PRIORITY_SCHEDULING .\"O in \fI\fP. POSIX システムで .BR sched_yield () は \fI\fP に .B _POSIX_PRIORITY_SCHEDULING が定義されている場合にのみ使用可能である。 .\"O Strategic calls to .\"O .BR sched_yield () .\"O can improve performance by giving other threads or processes .\"O a chance to run when (heavily) contended resources (e.g., mutexes) .\"O have been released by the caller. .\"O Avoid calling .\"O .BR sched_yield () .\"O unnecessarily or inappropriately .\"O (e.g., when resources needed by other .\"O schedulable threads are still held by the caller), .\"O since doing so will result in unnecessary context switches, .\"O which will degrade system performance. .BR sched_yield () を戦略的に呼び出すことで、(極度に) 競合するリソース (mutex など) を呼び出し元が解放した際に他のスレッドやプロセスに実行機会を与えることで、 性能を上げることができる。 .BR sched_yield () を必要もないのに呼び出したり、不適切な場面 (例えば、他のスケジューリング 対象となるスレッドが必要とするリソースを呼び出し元が保持したままの状態) で呼び出したりするのは避けること。なぜなら、 .BR sched_yield () の呼び出しより不必要なコンテキストスイッチが起こり、システム性能が 劣化する結果になるからである。 .\"O .SH "SEE ALSO" .SH 関連項目 .\"O .BR sched_setscheduler (2) .\"O for a description of Linux scheduling. Linux のスケージュリング(scheduling)については .BR sched_setscheduler (2) を参照せよ。 .PP .I Programming for the real world \- POSIX.4 by Bill O. Gallmeister, O'Reilly & Associates, Inc., ISBN 1-56592-074-0