教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 学前教育 >

山大操作系统课程设计报告(全套)(5)

来源:网络收集 时间:2026-05-20
导读: 3. Nachos原来实现AddressSpace分配的时候没有使用bitmap来寻找空闲页,而是直接的从0号内存空间 开始分配,因而需要修改成使用bitmap的find函数分配内存空间 其中,要声明一个位试图的是对象,在AddrSpace中 并且

3. Nachos原来实现AddressSpace分配的时候没有使用bitmap来寻找空闲页,而是直接的从0号内存空间 开始分配,因而需要修改成使用bitmap的find函数分配内存空间 其中,要声明一个位试图的是对象,在AddrSpace中 并且数据段代码段按页存储。 4. 计算加载一个程序需要的页表的数目 5. 实现Nachos的系统调用,采用的是触发异常中断的,在userprog/exception.cc,添加SC_Exec异常, 存放要执行的文件的路径的字符串的首地址存放在4号寄存器中,因此可以通过这个方式找到文件的路径, 从而使用文件系统提供的方法打开这个文件: 6. 结果分析: 编译成功之后,输入命令 ./nachos –x ../test/Exec.noff 运行结果: lu@ubuntu:~/csc2404/nachos-3.4/code/userprog$ ./nachos -x ../test/exec.noff page table dump: 12 pages in total ========================================================= VirtPage, PhysPage 0, 0 1, 1 2, 2 3, 3 4, 4 5, 5 6, 6 7, 7 8, 8 9, 9 10, 10 11, 11 =========================================================== the allocated physical Address:0 he address in the executable file :40 copy size 128 the allocated physical Address:128 he address in the executable file :168 copy size 128 the allocated physical Address:256 he address in the executable file :296 copy size 128 SC_Exec in exceptionHandler The value of the register 4 is, .i.e. the address of the String 272 add content of fn is now: 742f2e2e the char view is . . / t add content of fn is now: 2f747365 the char view is e s t / add content of fn is now: 746c6168 the char view is h a l t add content of fn is now: 666f6e2e the char view is . n o f add content of fn is now: 66 the char view is f add content of fn is now: 0 the char view is add content of fn is now: 0 the char view is add content of fn is now: 0 the char view is add content of fn is now: 0 the char view is add content of fn is now: 0 the char view is Exec file is ../test/halt.noff page table dump: 11 pages in total ========================================================= VirtPage, PhysPage 0, 12 1, 13 2, 14 3, 15 4, 16 5, 17 6, 18 7, 19 8, 20 9, 21 10, 22 =========================================================== the allocated physical Address:1536 he address in the executable file :40 copy size 128 the allocated physical Address:1664 he address in the executable file :168 copy size 128 the allocated physical Address:1792 he address in the executable file :296 copy size 128 Machine halting! Ticks: total 50, idle 0, system 10, user 40 Disk I/O: reads 0, writes 0 Console I/O: reads 0, writes 0 Paging: faults 0 Network I/O: packets received 0, sent 0 Cleaning up... lu@ubuntu:~/csc2404/nachos-3.4/code/userprog$ 加载进来的程序的地址空间没有覆盖原来那个程序的地址空间,使用新的地址空间去执行关机操作 Machine halting! 实现了一个程序加载另一个程序运行。 (实验所在路径: csc2404/nachos-3.4/code/ multiProcess 主要修改的文件,addrspace.cc exception.cc ) 结论分析与体会: Nachos之前没有实现按页分配地址空间,物理页和逻辑页地址一致,而且数据段代码段连续分配 每当一个新的用户程序建立的时候,虚拟地址和物理地址都是从0开始分配,这样新的用户程序 将会冲掉原来在物理0开始的程序。 因而使用位示图分配物理地址。使用bitmap的find函数分配虚存对应的物理地址,在为数据段和 代码段写入数据的时候是以扇区为单位的,而不是原有的连续一个文件的读入连续的内存。 Nachos操作系统通过中断的方式实现系统调用。需要增加userprog/exception.cc中的内容,即 必须在此类中添加处理Exec的方法。 返回

…… 此处隐藏:870字,全部文档内容请下载后查看。喜欢就下载吧 ……
山大操作系统课程设计报告(全套)(5).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/598633.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)