介绍了内核中task_struct结构体部分重要的成员变量的含义。
//https://elixir.bootlin.com/linux/v4.9.81/source/include/linux/sched.h#L1485
struct task_struct {
volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
void *stack; //内核栈
int on_rq;
int prio, static_prio, normal_prio;
unsigned int rt_priority;
const struct sched_class *sched_class; //调度器类
struct sched_entity se; //cfs进程调度实体
struct sched_rt_entity rt; //rt进程调度实体
struct task_group *sched_task_group;
struct sched_dl_entity dl; //deadline进程调度实体
unsigned int policy; //调度策略
struct list_head tasks; //init_task的该链表记录了所有的进程
struct mm_struct *mm, *active_mm;
pid_t pid;
pid_t tgid;
/* PID/PID hash table linkage. */
struct pid_link pids[PIDTYPE_MAX];
struct list_head thread_group;
struct list_head thread_node;
/* namespaces */
struct nsproxy *nsproxy;
struct task_struct __rcu *real_parent; /* real parent process */
struct task_struct __rcu *parent; /* recipient of SIGCHLD, wait4() reports */
struct list_head children; /* list of my children */
struct list_head sibling; /* linkage in my parent's children list */
struct task_struct *group_leader; /* threadgroup leader */
char comm[TASK_COMM_LEN]; //相应的程序名
struct fs_struct *fs; //用来表示进程与文件系统的联系,包括当前目录和根目录
struct files_struct *files; //表示进程当前打开的文件
struct signal_struct *signal; //进程的信号描述符
struct sighand_struct *sighand; //进程的信号处理程序
/* CPU-specific state of this task */
struct thread_struct thread;
int exit_code;
};