Chinaunix首页 | 论坛 | 博客
  • 博客访问: 829811
  • 博文数量: 155
  • 博客积分: 4004
  • 博客等级: 中校
  • 技术积分: 2070
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-19 11:37
文章分类

全部博文(155)

文章存档

2014年(3)

2013年(9)

2012年(28)

2011年(20)

2010年(29)

2009年(66)

我的朋友

分类: LINUX

2011-10-18 17:35:22

[root@localhost ~]# cat /proc/6873/stat
6873 (a.out) R 6723 6873 6723 34819 6873 8388608 77 0 0 0 41958 31 0 0 25 0 3 0 5882654 1409024 56 4294967295 134512640 134513720 3215579040 0 2097798 0 0 0 0 0 0 0 17 0 0 0 [root@localhost ~]#


每个参数意思为:
参数 解释
pid=6873 进程(包括轻量级进程,即线程)号
comm=a.out 应用程序或命令的名字
task_state=R 任务的状态,R:runnign, S:sleeping (TASK_INTERRUPTIBLE), D:disk sleep (TASK_UNINTERRUPTIBLE), T: stopped, T:tracing stop,Z:zombie, X:dead
ppid=6723 父进程ID
pgid=6873 线程组号
sid=6723 c该任务所在的会话组ID
tty_nr=34819(pts/3) 该任务的tty终端的设备号,INT(34817/256)=主设备号,(34817-主设备号)=次设备号
tty_pgrp=6873 终端的进程组号,当前运行在该任务所在终端的前台任务(包括shell 应用程序)的PID。
task->flags=8388608 进程标志位,查看该任务的特性
min_flt=77 该任务不需要从硬盘拷数据而发生的缺页(次缺页)的次数
cmin_flt=0 累计的该任务的所有的waited-for进程曾经发生的次缺页的次数目
maj_flt=0 该任务需要从硬盘拷数据而发生的缺页(主缺页)的次数
cmaj_flt=0 累计的该任务的所有的waited-for进程曾经发生的主缺页的次数目
utime=1587 该任务在用户态运行的时间,单位为jiffies
stime=1 该任务在核心态运行的时间,单位为jiffies
cutime=0 累计的该任务的所有的waited-for进程曾经在用户态运行的时间,单位为jiffies
cstime=0 累计的该任务的所有的waited-for进程曾经在核心态运行的时间,单位为jiffies
priority=25 任务的动态优先级
nice=0 任务的静态优先级
num_threads=3 该任务所在的线程组里线程的个数
it_real_value=0 由于计时间隔导致的下一个 SIGALRM 发送进程的时延,以 jiffy 为单位.
start_time=5882654 该任务启动的时间,单位为jiffies
vsize=1409024(B) 该任务的虚拟地址空间大小(
很多说明上在此误导为vsize的单位为page实际是不正确的
rss=56(page) 该任务当前驻留物理地址空间的大小
Number of pages the process has in real memory,minu 3 for administrative purpose.
这些页可能用于代码,数据和栈。
rlim=4294967295(bytes) 该任务能驻留物理地址空间的最大值
start_code=134512640 该任务在虚拟地址空间的代码段的起始地址
end_code=134513720 该任务在虚拟地址空间的代码段的结束地址
start_stack=3215579040 该任务在虚拟地址空间的栈的结束地址
kstkesp=0 esp(32 位堆栈指针) 的当前值, 与在进程的内核堆栈页得到的一致.
kstkeip=2097798 指向将要执行的指令的指针, EIP(32 位指令指针)的当前值.
pendingsig=0 待处理信号的位图,记录发送给进程的普通信号
block_sig=0 阻塞信号的位图
sigign=0 忽略的信号的位图
sigcatch=082985 被俘获的信号的位图
wchan=0 如果该进程是睡眠状态,该值给出调度的调用点
nswap 被swapped的页数,当前没用
cnswap 所有子进程被swapped的页数的和,当前没用
exit_signal=17 该进程结束时,向父进程所发送的信号
task_cpu(task)=0 运行在哪个CPU上
task_rt_priority=0 实时进程的相对优先级别
task_policy=0 进程的调度策略,0=非实时进程,1=FIFO实时进程;2=RR实时进程 


rss是实际占用内存,以页为单位存放,一般是4K每页,所有要乘以4 
vsize则是以B的单位存放,转化到K所以除1024 

  1. typedef struct statstruct_proc {  
  2.   int           pid;                      /** The process id. **/  
  3.   char          exName [_POSIX_PATH_MAX]; /** The filename of the executable **/  
  4.   char          state; /** 1 **/          /** R is running, S is sleeping,  
  5.                D is sleeping in an uninterruptible wait, 
  6.                Z is zombie, T is traced or stopped **/  
  7.   unsigned      euid,                      /** effective user id **/  
  8.                 egid;                      /** effective group id */                           
  9.   int           ppid;                     /** The pid of the parent. **/  
  10.   int           pgrp;                     /** The pgrp of the process. **/  
  11.   int           session;                  /** The session id of the process. **/  
  12.   int           tty;                      /** The tty the process uses **/  
  13.   int           tpgid;                    /** (too long) **/  
  14.   unsigned int  flags;                    /** The flags of the process. **/  
  15.   unsigned int  minflt;                   /** The number of minor faults **/  
  16.   unsigned int  cminflt;                  /** The number of minor faults with childs **/  
  17.   unsigned int  majflt;                   /** The number of major faults **/  
  18.   unsigned int  cmajflt;                  /** The number of major faults with childs **/  
  19.   int           utime;                    /** user mode jiffies **/  
  20.   int           stime;                    /** kernel mode jiffies **/  
  21.   int       cutime;                   /** user mode jiffies with childs **/  
  22.   int           cstime;                   /** kernel mode jiffies with childs **/  
  23.   int           counter;                  /** process's next timeslice **/  
  24.   int           priority;                 /** the standard nice value, plus fifteen **/  
  25.   unsigned int  timeout;                  /** The time in jiffies of the next timeout **/  
  26.   unsigned int  itrealvalue;              /** The time before the next SIGALRM is sent to the process **/  
  27.   int           starttime; /** 20 **/     /** Time the process started after system boot **/  
  28.   unsigned int  vsize;                    /** Virtual memory size **/  
  29.   unsigned int  rss;                      /** Resident Set Size **/  
  30.   unsigned int  rlim;                     /** Current limit in bytes on the rss **/  
  31.   unsigned int  startcode;                /** The address above which program text can run **/  
  32.   unsigned int  endcode;                  /** The address below which program text can run **/  
  33.   unsigned int  startstack;               /** The address of the start of the stack **/  
  34.   unsigned int  kstkesp;                  /** The current value of ESP **/  
  35.   unsigned int  kstkeip;                 /** The current value of EIP **/  
  36.   int       signal;                   /** The bitmap of pending signals **/  
  37.   int           blocked; /** 30 **/       /** The bitmap of blocked signals **/  
  38.   int           sigignore;                /** The bitmap of ignored signals **/  
  39.   int           sigcatch;                 /** The bitmap of catched signals **/  
  40.   unsigned int  wchan;  /** 33 **/        /** (too long) **/  
  41.   int       sched,        /** scheduler **/  
  42.                 sched_priority;       /** scheduler priority **/  
  43.           
  44. } procinfo;  
阅读(6387) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

划舞鱼2015-09-21 11:30:40

请问struct statstruct_proc结构体在用户空间该怎么用呢,想试着编写下ps命令,能给点建议吗,谢谢