Unix-system-calls-nanosleep
[top]#
|http://www.google.com/[Google] | a|
Web | This Site |
選択した読書 Copyright©2014 by finddevguides |
[cols=",,,,,,,",] |
| | Home | | References | | Discussion Forums | | About TP
[width="100%",cols="100%",] |
a| == nanosleep()-Unix、Linuxシステムコール
[[File:]] image :http://www.finddevguides.com/images/next.gif [next] image:http://www.finddevguides.com/add- this.gif [AddThisソーシャルブックマークボタン]
広告
NAME
nanosleep-指定された時間だけ実行を一時停止します
概要
- #define _POSIX_C_SOURCE 199309 * *#include <time.h> *
- int nanosleep(const struct timespec * req 、struct timespec * rem ); *
説明
構造_timespec_は、ナノ秒の精度で時間間隔を指定するために使用されます。 _ <time.h> _で指定され、次の形式を持ちます。
struct timespec { time_t tv_sec; /*seconds*/ long tv_nsec; /*nanoseconds*/ }; |
ナノ秒フィールドの値は、0から999999999の範囲でなければなりません。
返り値
要求された間隔で正常にスリープすると、 nanosleep ()は0を返します。 呼び出しがシグナルハンドラーによって中断されるか、エラーが発生した場合、-1を返し、_errno_がエラーを示すように設定されます。
エラー
Tag | Description |
---|---|
EFAULT | Problem with copying information from user space. |
*EINTR * | The pause has been interrupted by a non-blocked signal that was delivered to the process. The remaining sleep time has been written into* rem so that the process can easily call nanosleep() again and continue with the pause. |
EINVAL | The value in the tv_nsec field was not in the range 0 to 999999999 or tv_sec was negative. |
BUGS
古い動作
より正確な一時停止を必要とするアプリケーションをサポートするために(たとえば、一部のタイムクリティカルなハードウェアを制御するため)、 nanosleep ()は、 _SCHED_FIFO_や_SCHED_RR_などのリアルタイムポリシー。 この特別な拡張機能はカーネル2.5.39で削除されたため、現在の2.4カーネルには存在しますが、2.6カーネルには存在しません。
Linux 2.4では、 nanosleep ()がシグナル(たとえば、SIGTSTP)によって停止された場合、SIGCONTシグナルによってプロセスが再開された後、呼び出しはエラー EINTR で失敗します。 システムコールがその後再起動された場合、プロセスが停止状態で費やした時間はスリープ間隔に対してカウントされません。
準拠
POSIX.1-2001。
関連項目
[[File:]] image :http://www.finddevguides.com/images/next.gif [next] [[File:]]
広告
|
[cols="^",] |
|Advertisements