LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1686|回复: 0

thread_info 放栈顶的实现

[复制链接]
发表于 2007-11-5 17:25:51 | 显示全部楼层 |阅读模式
以下是小弟的一些拙见:
很多的书上都说了,thread_info是放在内核栈的栈顶上的,之前一直没弄明白, 现在把自己的理解分享下:
每个任务都有一个task_struct, 而task_struct内一个thread_info的结构体,把thread_info 放栈顶是通过使用 union thread_union 来实现的,
union thread_union定义在sched.h,
union thread_union {
        struct thread_info thread_info;
        unsigned long stack[THREAD_SIZE/sizeof(long)];
};

这样,thread_info就在内核栈上了,因为栈是向下生长的,于是thread_info 就处于栈顶了!

个人愚见!!

...........................
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表