在内核代码中有一个 union,就是将 task_struct、thread_info 以及 stack 放到一起的。当然这个具体放不放在一起,得看宏定义的情况: // include\linux\sched.h union thread_union { #ifndef CONFIG_ARCH_TASK_STRUCT_ON_STACK struct task_struct task; #endif #ifndef CONFIG_THREAD_INFO_IN_TASK struct th...
int on_rq;int prio;int static_prio;int normal_prio;unsigned int rt_priority;conststruct sched_class*sched_class;struct sched_entity se;struct sched_rt_entity rt;#ifdefCONFIG_CGROUP_SCHEDstruct task_group*sched_task_group;#endif struct sched_dl_entity dl;#ifdefCONFIG_UCLAMP_TASK/* Clamp valu...
#ifdefCONFIG_SCHED_INFO struct sched_infosched_info; #endif //... pid_t pid; pid_t tgid; //... }; 用一副图来表示: 这样设计的好处就是,得到stack,thread_info或task_struct任意一个数据结构的地址,就可以很快得到另外两个数据的地址。 我们可以通过crash工具在ubuntu系统上做个实验,来窥视一下某...
sched_class结构体表示调度类,目前内核中有实现以下四种: AI检测代码解析 extern const struct sched_class stop_sched_class; extern const struct sched_class dl_sched_class; extern const struct sched_class rt_sched_class; extern const struct sched_class fair_sched_class; extern const struct 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; ...
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 sched_info sched_info; struct list_head tasks; //指向进程PCB的指针 struct mm_struct *mm; struct mm_struct *active_mm; int exit_state; int exit_code; int exit_signal; /* The signal sent when the parent dies: */ int pdeath_signal; /* JOBCTL_*, siglock protected: */ unsign...
unsignedshortmigration_flags;structsched_infosched_info; structlist_headtasks;//指向进程PCB的指针structmm_struct*mm;structmm_struct*active_mm; intexit_state;intexit_code;intexit_signal;/* The signal sent when the parent dies: */intpdeath_signal;/* JOBCTL_*, siglock protected: */unsignedlong...
Linux内核通过一个被称为进程描述符的task_struct结构体来管理进程,这个结构体包含了一个进程所需的所有信息。它定义在include/linux/sched.h文件中。 谈到task_struct结构体,可以说她是linux内核源码中最复杂的一个结构体了,成员之多,占用内存之大。
在内核代码里面采用一个 union将thread_info和stack 放在一起,在 include/linux/sched.h 中定义用以表示内核栈。由代码可见,这里根据架构不同可能采用旧版的task_struct直接放在内核栈,而新版的均采用thread_info,以节约空间。 union thread_union { #ifndef CONFIG_ARCH_TASK_STRUCT_ON_STACK struct task_struct ...