首页 | 互联网 | IT动态 | IT培训 | Cisco | Windows | Linux | Java | .Net | Oracle | 软件测试 | C/C++ | 嵌入式开发 | 存储世界 | 服务器
网络设备 | IDC | 安全 | 求职招聘 | 数字网校 | 网页设计 | 平面设计 | 技术专题 | 电子书下载 | 教学视频 | 源码下载 | 搜索 | 博客 | 论坛
中国IT实验室Linux频道
Google
首页 入门 Linux编程 系统管理 网络管理 Linux认证 Unix/BSD Linux数据库 Linux集群 Linux手册 Linux下载 Ubuntu 论坛 专题 RSS
您现在的位置: 中国IT实验室 >> Linux >> 系统管理 >> 内核技术 >> 正文

Linux操作系统内存管理的源码实现

 

  程序运行了,问题又来了。终于读到了“写时复制”和请求调页的部分。当程序访问的线性地址没有被映射到一个物理页面,或欲写操作的线性地址映射的物理页面仅是只读,都会产生一个页异常,然后就会转去页异常中断处理程序(int 14)执行,页异常中断处理程序(page.s)如下:


14 _page_fault:
 15         xchgl %eax,(%esp)
 16         pushl %ecx
 17         pushl %edx
 18         push %ds
 19         push %es
 20         push %fs
 21         movl x10,%edx
 22         mov %dx,%ds
 23         mov %dx,%es
 24         mov %dx,%fs
 25         movl %cr2,%edx
 26         pushl %edx
 27         pushl %eax
 28         testl ,%eax
 29         jne 1f
 30         call _do_no_page
 31         jmp 2f
 32 1:      call _do_wp_page
 33 2:      addl ,%esp
 34         pop %fs
 35         pop %es
 36         pop %ds
 37         popl %edx
 38         popl %ecx
 39         popl %eax
 40         iret


  根据error_code判断是缺页还是写保护引起的异常,然后去执行相应的处理程序段,先看写保护的处理吧。


247 void do_wp_page(unsigned long error_code,unsigned long address)
248 {
249 #if 0
250 /* we cannot do this yet: the estdio library writes to code space */
251 /* stupid, stupid. I really want the libc.a from GNU */
252         if (CODE_SPACE(address))
253                 do_exit(SIGSEGV);
254 #endif
255         un_wp_page((unsigned long *)
256                 (((address>>10) & 0xffc) + (0xfffff000 &
257                 *((unsigned long *) ((address>>20) &0xffc)))));
258
259 }

上一页  [1] [2] [3] [4] [5] [6] [7] 下一页

【责编:Kittoy】
中国IT教育
相关产品和培训
文章评论
 友情推荐链接
 专题推荐

 ·防范Linux病毒 打造没有病毒的乐土…
 ·Linux Shell编程实用指南…
 ·Linux日志分析与管理
 ·揭密Linux内存管理
 ·邮件服务Sendmail应用配置
 ·Linux 安全管理…
 ·Linux 下DNS服务器架设攻略…
 ·Linux 下的路由的配置与应用…
 ·专题:Apache实用手册
 ·全面剖析Linux文件系统
 今日更新
 认证培训
 频道精选
 Windows频道导航