通常,sleep
是GNUsleep
程序。该程序调用 GNU 函数xnanosleep
,后者又调用 Linuxnanosleep
系统调用。和:
nanosleep() suspends the execution of the calling thread until either
at least the time specified in *req has elapsed, or the delivery of a
signal that triggers the invocation of a handler in the calling thread
or that terminates the process.
Run Code Online (Sandbox Code Playgroud)
因此,根据定义,该进程并未运行(无论优先级如何),而是暂停。
测试一下:
sleep 10 & ps aux | grep $!
[1] 25682
muru 25682 0.0 0.0 7196 620 pts/13 SN 04:10 0:00 sleep 10
Run Code Online (Sandbox Code Playgroud)
该过程的状态是SN
:
S interruptible sleep (waiting for an event to complete)
N low-priority (nice to other users)
Run Code Online (Sandbox Code Playgroud)
忽略N
,我猜这就是它开始时的样子。所以 的有效状态sleep
是interruptible sleep
。