Linux0.11的内存管理函数memory.c学习注释

给linux0.11的内存管理函数memory.c作了个注释,现在还没时间和能力分析2。6内核下的,不过linux早期版本的东西,对于想写自己内核的来说,真的是个宝藏。

/*
* linux/mm/memory.c
*
* (C) 1991 Linus Torvalds
*/

/*
* demand-loading started 01.12.91 - seems it is high on the list of
* things wanted, and it should be easy to implement. - Linus
*/

/*
* Ok, demand-loading was easy, shared pages a little bit tricker. Shared
* pages started 02.12.91, seems to work. - Linus.
*
* Tested sharing by executing about 30 /bin/sh: under the old kernel it
* would have taken more than the 6M I have free, but it worked well as
* far as I could see.
*
* Also corrected some "invalidate()"s - I wasn't doing enough of them.
*/

#include

#include

#include
#include
#include

volatile void do_exit(long code);

static inline volatile void oom(void)
{
printk("out of memory\n\r");
do_exit(SIGSEGV);
}

/* 刷新页变换高速缓冲,cr3指向页目录表的基地址
为了获得最大的地址转换效率,处理器把最近使用的页表数据存储在一个芯片内的缓存中。
只有当所要的地址转换信息没有在缓存中时,才有访问两级页表的必要。
*/
#define invalidate() \
__asm__("movl %%eax,%%cr3"::"a" (0))

/* 下面的宏定义要与head.s配合使用,改变他们的大小也一定要改变head.s中相关变量大小 */

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzwfwx.html