1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (C) 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-10 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
.\" First version written
.\" Modified, 2004-10-24, aeb
.\"
.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
.\" all rights reserved.
.\" Translated, 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated 1999-02-27, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated 2003-09-15, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2005-02-10, Akihiro MOTOKI
.\" Updated 2006-07-23, Akihiro MOTOKI, LDP v2.36
.\" Updated 2006-08-13, Akihiro MOTOKI, LDP v2.39
.\"
.\"WORD: puase
.\"WORD: sleep
.\"WORD: signal ʥ
.\"WORD: NULL NULL
.\"WORD: block ػ(block)
.\"WORD: kernel ͥ
.\"WORD: real-time ꥢ롦
.\"WORD: schedule 塼
.\"WORD: busy wait ӥ
.\"
.TH NANOSLEEP 2 2007-07-26 "Linux" "Linux Programmer's Manual"
.SH ̾
nanosleep \- ꤵ줿֤δ֡¹Ԥߤ
.SH
.B #include <time.h>
.sp
.BI "int nanosleep(const struct timespec *" req ", struct timespec *" rem );
.sp
.in -4n
glibc εǽޥ
.RB ( feature_test_macros (7)
):
.in
.sp
.BR nanosleep ():
_POSIX_C_SOURCE\ >=\ 199309L
.SH
.BR nanosleep ()
ϡʤȤ
.I *req
ǻꤵ줿֤δ֡ץμ¹Ԥٱ䤵롣
ץ˥ʥ뤬줿ˤϡ
ꤵ줿֤ãʤƤ֤뤳Ȥ롣
ξ \-1 ֤\fIerrno\fP
.B EINTR
ꤷ
.I rem
NULL Ǥʤ
.I rem
ؤƤ빽¤Τ˻Ĥλ֤Ǽ롣
.I *rem
ͤȤȡ
.BR nanosleep ()
⤦ٸƤӽФơꤷ֤ߤ
λ뤳ȤǤ롣
ʥùߤλֳִ֤ꤹΤ
.I timespec
¤ΤѤ롣ι¤Τ
.I <time.h>
ƤꡢʲΤ褦ʷǤ:
.sp
.in +4n
.nf
time_t tv_sec; /* */
long tv_nsec; /* ʥ */
};
.fi
.in
.PP
ʥäΥեɤͤ 0 999999999 ϰϤˤʤФʤʤ
.BR sleep (3)
.BR usleep (3)
٤
.BR nanosleep ()
ˤϰʲ:
.IP \(bu 3
ʥαƶʤ
.IP \(bu 3
POSIX ˤäɸಽ줿ؿǤ롣
.IP \(bu 3
⤤ʬǽƤ롣
.IP \(bu 3
ʥˤäǤ줿ˡߤ³뤳ȤñǤ롣
.SH ֤
ᤵ줿֤ߤ硢
.BR nanosleep ()
0 ֤ƤӽФʥϥɥˤޤ줿ꡢ
顼ȯϡ\-1 ֤
.I errno
˥顼Ƥͤꤹ롣
.SH 顼
.TP
.B EFAULT
桼֤ξΥԡ꤬ä
.TP
.B EINTR
ػ (block) Ƥʤʥ뤬ץơ
ߤǤ줿
ץñ
.BR nanosleep ()
ƤӸƤӽФߤ³뤳ȤǤ褦ˡ
Ĥ֤ \fI*rem\fP ˳Ǽ롣
.TP
.B EINVAL
.I tv_nsec
եɤͤ 0 999999999 ޤǤϰϤˤʤä
.I tv_sec
Ǥä
.SH
POSIX.1-2001.
.SH Х
ߤ
.BR nanosleep ()
μ̤ΥͥΥ˴ŤƤ롣ͥΥ
1/\fIHZ\fP\ äʬǽäƤ
.RB ( time (7)
)Τᡢ
.BR nanosleep ()
ϾʤȤꤵ줿ɬߤ뤬ץƤӼ¹ԤǤ
褦ˤʤޤǤ˻ꤵ줿֤ 10 ms ;פˤ롣Ʊͳǡ
ʥ뤬줿 \fI*rem\fP ֤ͤϡ̾
ºݤͤ꾮ʤǾ 1/\fIHZ\fP äܿڤ夲롣
.SS ư
(㤨С֤פʰ̣ĥϡɥ椹ʤ)
ΤߤɬפȤ륢ץꥱб뤿ˡ
.BR nanosleep ()
ϡޥ٤ΥӥȤѤ뤳Ȥǡ
2\ ms ʲߤԤȤǤ
âεǽѤˤϡƤӽФΥץ
.B SCHED_FIFO
.B SCHED_RR
Ȥäꥢ륿ࡦݥꥷθǥ塼Ƥ
ɬפä
̤ʳĥϥͥ 2.5.39 Ǻ줿äơ
ߤ 2.4 ΥͥˤϤεǽ¸ߤ뤬
2.6ΥͥˤϤʤ
.PP
Linux 2.4 Ǥϡ
.BR nanosleep ()
.RB ( SIGTSTP
ʤɤ) ʥˤߤ줿硢
.BR nanosleep ()
θƤӽФ
.B SIGCONT
ʥˤץκƳ
.B EINTR
顼ǼԤ롣
ƥॳ뤬θǺƥȤ줿硢
ץ߾֤ˤ֤˷вᤷ֤
ߴ֤Ȥƥȡ֤ʤס
.SH Ϣ
.BR sched_setscheduler (2),
.BR sleep (3),
.BR timer_create (3),
.BR usleep (3),
.BR time (7)
|