首页 > 代码库 > [Linux]进程(十二)--task_struct结构体
[Linux]进程(十二)--task_struct结构体
[cpp] view plaincopy
- struct task_struct {
- volatile long state; /* -1 不可运行, 0 可运行, >0 表示停止 */
- void *stack;
- atomic_t usage;
- unsigned long flags; /* 每进程标志 */
- unsigned long ptrace;
- int lock_depth; /* 大内核锁深度 */
- int prio, static_prio, normal_prio;
- struct list_head run_list;
- const struct sched_class *sched_class;
- struct sched_entity se;
- unsigned short ioprio;
- unsigned long policy;
- cpumask_t cpus_allowed;
- unsigned int time_slice;
- #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
- struct sched_info sched_info;
- #endif
- struct list_head tasks;
- /*
- * ptrace_list/ptrace_children forms the list of my children
- * that were stolen by a ptracer.
- */
- struct list_head ptrace_children;
- struct list_head ptrace_list;
- struct mm_struct *mm, *active_mm;
- /* 进程状态 */
- struct linux_binfmt *binfmt;
- long exit_state;
- int exit_code, exit_signal;
- int pdeath_signal; /* 在父进程终止的时候发送的信号 */
- unsigned int personality;
- unsigned did_exec:1;
- pid_t pid;
- pid_t tgid;
- struct task_struct *real_parent; /* 真正的父进程(被调试的情况下) */
- struct task_struct *parent; /* 父进程 ,parent和real_parent的区别:real_parent是亲爹,调fork的那个,parent呢是干爹,大部分情况下亲爹干爹是一个人,ps看到的是干爹,什么时候亲爹干爹不一样的,比如有一种情况,比如亲爹死了,但是呢又得有一个父进程,比如1号进程就会被当成父进程。但进程不是1号fork出来的。*/
- struct list_head children; /* 子进程链表 */
- struct list_head sibling; /* 连接到父进程的子进程的链表 */
- struct task_struct *group_leader; /* 线程组组长 */
- /* PID与PID散列表的联系*/
- struct pid_link pids[PIDTYPE_MAX];
- struct list_head thread_group;
- struct completion *vfork_done; /* 用于vfork() */
- int __user *set_child_tid; /* CLONE_CHILD_SETTID */
- int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
- unsigned long rt_priority;
- cputime_t utime, stime, utimescaled, stimescaled;;
- unsigned long nvcsw, nivcsw; /* 上下文切换计数 */
- struct timespec start_time; /* 单调时间 */
- struct timespec real_start_time; /* 启动以来的时间 */
- unsigned long min_flt, maj_flt;
- cputime_t it_prof_expires, it_virt_expires;
- unsigned long long it_sched_expires;
- struct list_head cpu_timers[3];
- /* 进程身份凭据 */
- uid_t uid,euid,suid,fsuid;
- gid_t gid,egid,sgid,fsgid;
- struct group_info *group_info;
- kernel_cap_t cap_effective, cap_inheritable, cap_permitted;
- unsigned keep_capabilities:1;
- struct user_struct *user;
- char comm[TASK_COMM_LEN]; /* 去除路径后的可执行文件名称*/
- /* 文件系统信息 */
- int link_count, total_link_count;
- /* ipc stuff */
- struct sysv_sem sysvsem;
- /* 当前进程特定的cpu信息 */
- struct thread_struct thread;
- /* filesystem information */
- struct fs_struct *fs;
- /* open file information */
- struct files_struct *files;
- /* namespace */
- struct nsproxy *nsproxy;
- /* signal handlers */
- struct signal_struct *signal;
- struct sighand_struct *sighand;
- sigset_t blocked, real_blocked;
- sigset_t saved_sigmask; /* To be restored with TIF_RESTORE_SIGMASK */
- struct sigpending pending;
- unsigned long sas_ss_sp;
- size_t sas_ss_size;
- int (*notifier)(void *priv);
- void *notifier_data;
- sigset_t *notifier_mask;
- #ifdef CONFIG_SECURITY
- v oid *security;
- #endif
- /* 线程组跟踪 */
- u32 parent_exec_id;
- u32 self_exec_id;
- /* 日志文件系统信息 */
- void *journal_info;
- /* 虚拟内存状态 */
- struct reclaim_state *reclaim_state;
- struct backing_dev_info *backing_dev_info;
- struct io_context *io_context;
- unsigned long ptrace_message;
- siginfo_t *last_siginfo; /* For ptrace use. */
- ...
- };
atomic_t usage; 有几个进程正在使用此结构
[Linux]进程(十二)--task_struct结构体
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。