sched_yield

Section: System Calls (2)
Updated: 2026-02-08
Index JM Home Page roff page
 

名前

sched_yield - プロセッサーを空け渡す(yield)  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式

#include <sched.h>

int sched_yield(void);
 

説明

sched_yield() を呼び出すことで、呼び出したスレッドが CPU の使用権を手放すことができる。 そのスレッドは、そのスレッドの静的プライオリティのキューの末尾に 移動し、新しいスレッドが走り始める。  

返り値

On success, sched_yield() returns 0. On error, -1 is returned, and errno is set to indicate the error.  

エラー

Linux の実装では、 sched_yield() は常に成功する。  

標準規格

POSIX.1-2024.  

歴史

POSIX.1-2001 (but optional). POSIX.1-2008.

Before POSIX.1-2008, systems on which sched_yield() is available defined _POSIX_PRIORITY_SCHEDULING in <unistd.h>.  

警告

sched_yield() is intended for use with real-time scheduling policies (i.e., SCHED_FIFO or SCHED_RR). Use of sched_yield() with nondeterministic scheduling policies such as SCHED_OTHER is unspecified and very likely means your application design is broken.

sched_yield() を呼び出した時点で最大優先度のリストの中に呼び出し元のスレッドしか 存在しなければ、そのスレッドは呼び出し後も走り続けることになる。

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.  

関連項目

sched(7)


 

Index

名前
ライブラリ
書式
説明
返り値
エラー
標準規格
歴史
警告
関連項目

This document was created by man2html, using the manual pages.