[cpp] view plaincopy
 
  1. struct task_struct {  
  2.     volatile long state; /* -1 不可运行, 0 可运行, >0 表示停止 */  
  3.     void *stack;  
  4.     atomic_t usage;  
  5.     unsigned long flags; /* 每进程标志 */  
  6.     unsigned long ptrace;  
  7.     int lock_depth; /* 大内核锁深度 */  
  8.     int prio, static_prio, normal_prio;  
  9.     struct list_head run_list;  
  10.     const struct sched_class *sched_class;  
  11.     struct sched_entity se;  
  12.     unsigned short ioprio;  
  13.     unsigned long policy;  
  14.     cpumask_t cpus_allowed;  
  15.     unsigned int time_slice;  
  16. #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)  
  17.     struct sched_info sched_info;  
  18. #endif  
  19.     struct list_head tasks;  
  20.     /* 
  21.     * ptrace_list/ptrace_children forms the list of my children 
  22.     * that were stolen by a ptracer. 
  23.     */  
  24.     struct list_head ptrace_children;  
  25.     struct list_head ptrace_list;  
  26.     struct mm_struct *mm, *active_mm;  
  27. /* 进程状态 */  
  28.     struct linux_binfmt *binfmt;  
  29.     long exit_state;  
  30.     int exit_code, exit_signal;  
  31.     int pdeath_signal; /* 在父进程终止的时候发送的信号 */  
  32.     unsigned int personality;  
  33.     unsigned did_exec:1;  
  34.     pid_t pid;  
  35.     pid_t tgid;  
  36.     struct task_struct *real_parent; /* 真正的父进程(被调试的情况下) */  
  37.     struct task_struct *parent; /* 父进程 ,parent和real_parent的区别:real_parent是亲爹,调fork的那个,parent呢是干爹,大部分情况下亲爹干爹是一个人,ps看到的是干爹,什么时候亲爹干爹不一样的,比如有一种情况,比如亲爹死了,但是呢又得有一个父进程,比如1号进程就会被当成父进程。但进程不是1号fork出来的。*/  
  38.     struct list_head children; /* 子进程链表 */  
  39.     struct list_head sibling; /* 连接到父进程的子进程的链表 */  
  40.     struct task_struct *group_leader; /* 线程组组长 */  
  41.     /* PID与PID散列表的联系*/  
  42.     struct pid_link pids[PIDTYPE_MAX];  
  43.     struct list_head thread_group;  
  44.     struct completion *vfork_done; /* 用于vfork() */  
  45.     int __user *set_child_tid; /* CLONE_CHILD_SETTID */  
  46.     int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */  
  47.     unsigned long rt_priority;  
  48.     cputime_t utime, stime, utimescaled, stimescaled;;  
  49.     unsigned long nvcsw, nivcsw; /* 上下文切换计数 */  
  50.     struct timespec start_time; /* 单调时间 */  
  51.     struct timespec real_start_time; /* 启动以来的时间 */  
  52.     unsigned long min_flt, maj_flt;  
  53.     cputime_t it_prof_expires, it_virt_expires;  
  54.     unsigned long long it_sched_expires;  
  55.     struct list_head cpu_timers[3];  
  56. /* 进程身份凭据 */  
  57.     uid_t uid,euid,suid,fsuid;  
  58.     gid_t gid,egid,sgid,fsgid;  
  59.     struct group_info *group_info;  
  60.     kernel_cap_t cap_effective, cap_inheritable, cap_permitted;  
  61.     unsigned keep_capabilities:1;  
  62.     struct user_struct *user;  
  63.     char comm[TASK_COMM_LEN]; /* 去除路径后的可执行文件名称*/  
  64. /* 文件系统信息 */  
  65.     int link_count, total_link_count;  
  66. /* ipc stuff */  
  67.     struct sysv_sem sysvsem;  
  68. /* 当前进程特定的cpu信息 */  
  69.     struct thread_struct thread;  
  70. /* filesystem information */  
  71.     struct fs_struct *fs;  
  72. /* open file information */  
  73.     struct files_struct *files;  
  74. /* namespace */  
  75.     struct nsproxy *nsproxy;  
  76. /* signal handlers */  
  77.     struct signal_struct *signal;  
  78.     struct sighand_struct *sighand;  
  79.     sigset_t blocked, real_blocked;  
  80.     sigset_t saved_sigmask; /* To be restored with TIF_RESTORE_SIGMASK */  
  81.     struct sigpending pending;  
  82.     unsigned long sas_ss_sp;  
  83.     size_t sas_ss_size;  
  84.     int (*notifier)(void *priv);  
  85.     void *notifier_data;  
  86.     sigset_t *notifier_mask;  
  87. #ifdef CONFIG_SECURITY  
  88. v   oid *security;  
  89. #endif  
  90. /* 线程组跟踪 */  
  91.     u32 parent_exec_id;  
  92.     u32 self_exec_id;  
  93. /* 日志文件系统信息 */  
  94.     void *journal_info;  
  95. /* 虚拟内存状态 */  
  96.     struct reclaim_state *reclaim_state;  
  97.     struct backing_dev_info *backing_dev_info;  
  98.     struct io_context *io_context;  
  99.     unsigned long ptrace_message;  
  100.     siginfo_t *last_siginfo; /* For ptrace use. */  
  101. ...  
  102. };  

atomic_t usage; 有几个进程正在使用此结构

posted on 2014-10-26 08:41  知了112  阅读(952)  评论(0编辑  收藏  举报