<s>
A	O
computer	B-Application
program	I-Application
(	O
process	B-Operating_System
,	O
task	B-General_Concept
,	O
or	O
thread	B-Operating_System
)	O
may	O
sleep	O
,	O
which	O
places	O
it	O
into	O
an	O
inactive	B-Operating_System
state	I-Operating_System
for	O
a	O
period	O
of	O
time	O
.	O
</s>
<s>
Eventually	O
the	O
expiration	O
of	O
an	O
interval	O
timer	O
,	O
or	O
the	O
receipt	O
of	O
a	O
signal	B-Operating_System
or	O
interrupt	B-Application
causes	O
the	O
program	O
to	O
resume	O
execution	O
.	O
</s>
<s>
A	O
typical	O
sleep	O
system	B-Operating_System
call	I-Operating_System
takes	O
a	O
time	O
value	O
as	O
a	O
parameter	O
,	O
specifying	O
the	O
minimum	O
amount	O
of	O
time	O
that	O
the	O
process	B-Operating_System
is	O
to	O
sleep	O
before	O
resuming	O
execution	O
.	O
</s>
<s>
For	O
higher	O
precisions	O
,	O
it	O
is	O
necessary	O
to	O
use	O
a	O
busy	B-Operating_System
loop	I-Operating_System
over	O
,	O
such	O
as	O
the	O
one	O
used	O
in	O
gnulib	B-Application
.	O
</s>
<s>
On	O
Unix-like	B-Operating_System
and	O
other	O
POSIX	O
operating	O
systems	O
,	O
the	O
sleep( )	O
function	O
is	O
called	O
providing	O
a	O
single	O
parameter	O
of	O
type	O
unsigned	O
integer	O
of	O
the	O
number	O
of	O
seconds	O
to	O
sleep	O
.	O
</s>
<s>
In	O
Windows	B-Library
API	I-Library
:	O
</s>
<s>
In	O
Unix	O
or	O
POSIX	O
system	B-Operating_System
calls	I-Operating_System
:	O
</s>
<s>
Sleep	O
causes	O
the	O
thread	B-Operating_System
or	O
process	B-Operating_System
to	O
give	O
up	O
the	O
remainder	O
of	O
its	O
time	O
slice	O
and	O
stay	O
in	O
the	O
Not	O
Runnable	O
state	O
for	O
the	O
specified	O
duration	O
.	O
</s>
<s>
While	O
there	O
is	O
generally	O
a	O
guarantee	O
for	O
the	O
minimum	O
time	O
period	O
,	O
there	O
is	O
no	O
strict	O
guarantee	O
that	O
the	O
thread	B-Operating_System
will	O
run	O
immediately	O
or	O
soon	O
,	O
or	O
even	O
at	O
all	O
,	O
once	O
the	O
specified	O
time	O
has	O
passed	O
.	O
</s>
<s>
It	O
is	O
up	O
to	O
the	O
scheduler	O
's	O
discretion	O
,	O
and	O
dependent	O
on	O
thread	B-Operating_System
priorities	O
and	O
implementation	O
details	O
such	O
as	O
timer	O
resolutions	O
when	O
the	O
sleeping	O
thread	B-Operating_System
will	O
run	O
again	O
.	O
</s>
<s>
On	O
POSIX	O
systems	O
,	O
the	O
nanosleep	O
and	O
related	O
syscalls	B-Operating_System
are	O
interruptible	O
by	O
signals	O
,	O
returning	O
the	O
remaining	O
sleep	O
time	O
.	O
</s>
<s>
The	O
sleep	O
library	O
function	O
,	O
on	O
the	O
other	O
hand	O
,	O
is	O
implemented	O
via	O
the	O
alarm	O
syscall	B-Operating_System
on	O
many	O
older	O
systems	O
,	O
thus	O
it	O
only	O
works	O
by	O
delivering	O
a	O
signal	B-Operating_System
.	O
</s>
<s>
The	O
Windows	O
Sleep	O
function	O
is	O
non-interruptible	O
due	O
to	O
absence	O
of	O
signals	O
(	O
other	O
than	O
the	O
thread	B-Operating_System
or	O
its	O
process	B-Operating_System
being	O
terminated	O
)	O
,	O
although	O
the	O
related	O
SleepEx	O
function	O
can	O
be	O
used	O
to	O
put	O
the	O
thread	B-Operating_System
into	O
an	O
alertable	O
state	O
,	O
allowing	O
APC	O
calls	O
being	O
made	O
while	O
the	O
thread	B-Operating_System
is	O
sleeping	O
.	O
</s>
<s>
Also	O
,	O
a	O
thread	B-Operating_System
can	O
technically	O
be	O
"	O
interrupted	O
"	O
in	O
case	O
e.g.	O
</s>
<s>
the	O
process	B-Operating_System
terminates	O
due	O
to	O
an	O
exception	O
in	O
a	O
different	O
thread	B-Operating_System
.	O
</s>
<s>
Some	O
system	B-Operating_System
programs	I-Operating_System
that	O
never	O
terminate	O
execute	O
an	O
event	B-General_Concept
loop	I-General_Concept
,	O
going	O
to	O
sleep	O
at	O
the	O
start	O
of	O
each	O
cycle	O
and	O
waiting	O
for	O
some	O
event	O
to	O
awaken	O
them	O
.	O
</s>
<s>
Other	O
programs	O
periodically	O
poll	B-General_Concept
for	O
events	O
by	O
going	O
to	O
sleep	O
and	O
resuming	O
execution	O
after	O
a	O
specific	O
interval	O
of	O
time	O
.	O
</s>
<s>
Certain	O
kinds	O
of	O
heartbeat	B-Application
events	O
or	O
keep-alive	O
signals	O
can	O
be	O
generated	O
by	O
these	O
kinds	O
of	O
programs	O
.	O
</s>
<s>
An	O
uninterruptible	O
sleep	O
state	O
is	O
a	O
sleep	O
state	O
that	O
wo	O
n't	O
handle	O
a	O
signal	B-Operating_System
right	O
away	O
.	O
</s>
<s>
When	O
the	O
process	B-Operating_System
is	O
sleeping	O
uninterruptibly	O
,	O
signals	O
accumulated	O
during	O
the	O
sleep	O
will	O
be	O
noticed	O
when	O
the	O
process	B-Operating_System
returns	O
from	O
the	O
system	B-Operating_System
call	I-Operating_System
or	O
trap	B-Application
.	O
</s>
<s>
In	O
Unix-like	B-Operating_System
systems	I-Operating_System
the	O
command	O
'	O
ps	O
-l	O
'	O
uses	O
code	O
"	O
D	O
"	O
for	O
the	O
uninterruptible	O
sleep	O
state	O
of	O
a	O
process	B-Operating_System
.	O
</s>
<s>
Such	O
processes	O
cannot	O
be	O
killed	O
even	O
with	O
SIGKILL	B-General_Concept
and	O
the	O
only	O
non-sophisticated	O
way	O
to	O
get	O
rid	O
of	O
them	O
is	O
to	O
reboot	O
the	O
system	O
.	O
</s>
