您的位置:首页 > 运维架构 > Linux

linux-0.11,任务1的用户态堆栈,copy-on-write之后的堆栈!

2013-01-25 07:34 260 查看
下面是copy-on-write之后和之前的内存页,copy-on-write之前0x401ee50位于user_stack[]数组内。user_stack地址:0x1de6c。0x1ee5c处的地址0x5412既head.s中L6的地址:$L6。

copy-on-write之后位于0xffd000-0xffe000对应的内存页中。



下面是copy-on-write之前和之后页表项的变化:



看来Linus Torvalds的main.c中注释是不正确的。

/*

 *  linux/init/main.c

 *

 *  (C) 1991  Linus Torvalds

 */

#define __LIBRARY__

#include <unistd.h>

#include <time.h>

/*

 * we need this inline - forking from kernel space will result

 * in NO COPY ON WRITE (!!!), until an execve is executed. This

 * is no problem, but for the stack. This is handled by not letting

 * main() use the stack at all after fork(). Thus, no function

 * calls - which means inline code for fork too, as otherwise we

 * would use the stack upon exit from 'fork()'.

 *

 * Actually only pause and fork are needed inline, so that there

 * won't be any messing with the stack from main(), but we define

 * some others too.

 */
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: