linux kernel current宏

linux kernel current宏  

2012-04-15 10:46:23|  分类: linux 进程与进程 |  标签: |字号 订阅

1,先看个示意图吧.

linux kernel current宏 - wanny - wanny

2,每个进程在内核态下都会开辟一个内核栈,一般就是8KB,一般把thread_info这个结构体和
      内核栈放在一起,这样内核就可以很方便从ESP寄存器中获取当前CPU上正在运行的thread_info
      结构体的首地址,通过thread_info就可以找到PCB了。这个PCB就是当前进程的PCB。
      将esp中的值屏蔽掉末尾的13位即是thread_info的首地址。

3,每个进程都有个thread_info这个结构,这个结构和task_struct是一一对应的。
     具体的字段如下:(linux-2.6.38)
 26 struct thread_info {
 27         struct task_struct      *task;          /* main task structure */
 28         struct exec_domain      *exec_domain;   /* execution domain */
 29         __u32                   flags;          /* low level flags */
 30         __u32                   status;         /* thread synchronous flags */
 31         __u32                   cpu;            /* current CPU */
 32         int                     preempt_count;  /* 0 => preemptable,
 33                                                    <0 => BUG */
 34         mm_segment_t            addr_limit;
 35         struct restart_block    restart_block;
 36         void __user             *sysenter_return;
 37 #ifdef CONFIG_X86_32
 38         unsigned long           previous_esp;   /* ESP of the previous stack in
 39                                                    case of nested (IRQ) stacks
 40                                                 */
 41         __u8                    supervisor_stack[0];
 42 #endif
 43         int                     uaccess_err;
 44 };

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值