一 联合体 thread_union:表示一个进程的线程描述符和内核栈大小定义
union thread_union {
struct thread_info thread_info;
unsigned long stack[THREAD_SIZE/sizeof(long)];根据联合体的定义和作用,一个 thread_info的大小也就是栈的大小
};
线程描述符:----也可以理解成线程的”逻辑栈信息“,注意不是与cpu栈信息,这里仅仅是软件层面上线程的“栈信息”
struct thread_info {
unsigned long flags; /* low level flags */
int preempt_count; /* 0 => preemptable, <0 => bug */
mm_segment_t addr_limit; /* address limit */
struct task_struct *task; /* main task structure */
struct exec_domain *exec_domain; /* execution domain */
__u32 cpu; /* cpu */
__u32 cpu_domain; /* cpu domain */
struct cpu_context_save cpu_context; /* cpu context */-----cpu的寄存器 层面栈的信息
__u32 syscall; /* syscall number */
__u8 used_cp[16]; /* thread used copro */
unsigned long tp_value;
struct crunch_state crunchstate;
union fp_state fpstate __attribute__((aligned(8)));
union vfp_state vfpstate;
#ifdef CONFIG_ARM_THUMBEE
unsigned long thumbee_state; /* ThumbEE Handler Base register */
#endif
struct restart_block restart_block;
int cpu_excp;
void *regs_on_excp;
};
小结: thread_union与 thread_info 是一样的作用,只是 thread_union 做了一个stack大小的定义。
二 线程栈信息的建立流程
概述:首先 系统启动的时候,init线程首先分配了一个thread_union;以后其他的线程创建的时候,都是copy
多线程:ARM linux平台上线程栈信息的建立流程
最新推荐文章于 2022-02-20 13:57:28 发布