解释 ps 一般显示标识
在Linux 中使用 ps 会获得类似下列的进程展示
一般情况下都会存在stat 的属性
项目 | Value |
---|---|
stat | 进程状态 |
ppid | 父进程号,可以用getppid()获得 |
pid | 当前进程号,可以用getpid()获得 |
pgid | 表示组进程号 getgpid()获得 |
讲一下STAT 进程状态标识
那么接下来重点讲解一下STAT中的一系列表示
先放个原文
PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will
display to describe the state of a process:
D uninterruptible sleep (usually IO)
R running or runnable (on run queue)
S interruptible sleep (waiting for an event to complete)
T stopped, either by a job control signal or because it is being traced
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z defunct ("zombie") process, terminated but not reaped by its parent
For BSD formats and when the stat keyword is used, additional characters may be displayed:
< high-priority (not nice to other users)
N low-priority (nice to other users)
L has pages locked into memory (for real-time and custom IO)
s is a session leader
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+ is in the foreground process group
下面附带一些中文理解
标识 | 含义 |
---|---|
D | 不可中断 Uninterruptible sleep (usually IO) |
R | 正在运行,或在队列中的进程 |
S | 处于休眠状态 |
T | 停止或被追踪 |
Z | 僵尸进程 |
W | 进入内存交换(从内核2.6开始无效) |
X | 死掉的进程 |
特殊符号 | 含义 |
---|---|
< | 高优先级 |
N | 低优先级 |
L | 有些页被锁进内存 |
s | 包含子进程 |
+ | 位于后台的进程组 |
l | 多线程,克隆线程 multi-threaded (using CLONE_THREAD, like NPTL pthreads do) |
That`s all
最近又看到pcb和进程数的关系,不甚理解,下次再好好查查资料