linux进程介绍

Linux是一个多用户,多任务的 系统,能够同时运行多个用户的多个程序,就必然会产生不少的进程,而每一个进程会有不一样的状态。 在下文将对进程的R、S、D、T、Z、X 六种状态作个说明。node

 

PROCESS STATE CODESlinux

Here are thedifferent values that the s, stat and state output specifiers (header"STAT" or "S") will display to describe the state of aprocess.session

D Uninterruptiblesleep (usually IO)oracle

R Runningor runnable (on run queue)app

S Interruptiblesleep (waiting for an event to complete)异步

T Stopped,either by a job control signal or because it is being traced.spa

W paging(not valid since the 2.6.xx kernel)orm

X dead(should never be seen)blog

Z Defunct("zombie") process, terminated but not进程

reapedby its parent.

 

For BSD formatsand 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 haspages locked into memory (for real-time and custom IO)

s isa session leader

l ismulti-threaded (using CLONE_THREAD, like NPTL pthreads do)

+ is in the foreground process group

一. 查看进程的状态

1.1 使用PS命令

[root@localhost]# ps -a -opid,ppid,stat,command -u oracle

PID PPID STAT COMMAND

637 1Ss oracleXEZF (LOCAL=NO)

729 1Ss oracleXEZF (LOCAL=NO)

1144 1103 S+ top

1230 1Ss oracleXEZF (LOCAL=NO)

1289 1145 S+ vmstat 10

1699 1Ss oracleXEZF (LOCAL=NO)

1827 1294 R+ ps -a -opid,ppid,stat,command -u oracle

3410 1Ss ora_pmon_XEZF

3412 1Ss ora_psp0_XEZF

3414 1Ss ora_mman_XEZF

3416 1Ss ora_dbw0_XEZF

3488 1 Ssl /home/oracle_app/bin/tnslsnr LISTENER -inherit

11167 1Ss oracleXEZF (LOCAL=NO)

19323 1Ss oracleXEZF (LOCAL=NO)

 

用ps 的 – l 选项,得 到更详细的进程信息:

(1)F(Flag):一系列数字的和,表示进程的当前状态。这些数字的含义为:

00:若单独显示,表示此进程已被终止。

01:进程是核心进程的一部分,常驻于系统主存。如:sched,vhand,bdflush。

02:Parent is tracing process.

04 :Tracing parent's signal has stopped the process; the parentis waiting ( ptrace(S)).

10:进程在优先级低于或等于25时,进入休眠状态,并且不能用信号 唤醒,例如在等待一个inode被建立时。

20:进程被装入主存(primary memory)

40:进程被锁在主存,在事务完成前不能被置换。

 

(2) 进程状态:S(state)

O:进程正在处理器运行,这个状态历来木见过.

S:休眠状态(sleeping

R:等待运行(runable)R Running or runnable (on runqueue) 进程处于运行或就绪状态

I:空闲状态(idle

Z:僵尸状态(zombie

T:跟踪状态(Traced)

B:进程正在等待更多的内存

D:不可中断的深度睡眠,通常由IO引发,同步IO在作读或写操做时,cpu不能作其它事情,只能等待,这时进程处于这种状态,若是程序采用异步IO,这种状态应该就不多见到了

(3)C(cpuusage):cpu利 用率的估算值

1.2 使用Top命令中的S 字段

piduser pr ni virt res shrs %cpu%mem time+ command

11423oracle 16 0 627m170m168mR 32 9.0 4110:21oracle

3416oracle 15 0 650m158m138mS 0 8.4 0:07.12oracle

637oracle 15 0 629m 76m 73mS 0 4.0 0:04.31oracle 

相关文章
相关标签/搜索