[Linux]進程(十二)--task_struct結構體

來源:互聯網
上載者:User

標籤:blog   http   io   ar   使用   for   strong   sp   檔案   

[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; 有幾個進程正在使用此結構

[Linux]進程(十二)--task_struct結構體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.