多线程:ARM linux平台上线程栈信息的建立流程

  •   联合体  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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值