Jos-lab5 (上)
来源:互联网 发布:淘宝店铺发布宝贝属性 编辑:程序博客网 时间:2024/06/14 23:00
Exercise 1.i386_init
identifies the file system environment bypassing the typeENV_TYPE_FS
to your environment creationfunction,env_create
.Modifyenv_create
in env.c,so that it gives the file system environment I/O privilege,but never gives that privilege to any other environment.
在env_create()中加入如下的代码
417 if (type == ENV_TYPE_FS) {
418 e->env_tf.tf_eflags = e->env_tf.tf_eflags | FL_IOPL_3;
419 }
我原本直接write_eflags(),其实这只是改变了当前在kernel下的访问权限,并没有对这个enviroment造成影响。
Exercise 2.Implement the bc_pgfault
functions infs/bc.c.bc_pgfault
is a page fault handler, just like the oneyour wrote in the previous lab for copy-on-write fork, except thatits job is to load pages in from the disk in response to a pagefault. When writing this, keep in mind that (1)addr
may not be aligned to a block boundary and (2) ide_read
operates in sectors, not blocks.
36 addr = ROUNDDOWN(addr, PGSIZE);
37 if ((r = sys_page_alloc(0, addr, PTE_W|PTE_U|PTE_P))<0)
38 panic("%s, sys_page_alloc error: %e",__func__,r);
39 ide_read(blockno*BLKSECTS,addr,BLKSECTS);
原本用了page_alloc() & page_insert(),可是这是kernel里的API,在用户空间必须透过包装过sys call: sys_page_alloc()来调用。
Exercise 3.spawn
relies on the new syscallsys_env_set_trapframe
to initialize the state of thenewly created environment. Implementsys_env_set_trapframe
. Test your code by running theuser/spawnhello programfrom kern/init.c, which will attempt tospawn /hello from the file system.
145 struct Env *e;
146 int r = envid2env(envid, &e, 1);
147 if (r < 0){
148 cprintf("%s(),%d: return %d!\n",__func__,__LINE__,r);
149 return r;
150 }
152 user_mem_check(e, tf, sizeof(struct Trapframe), PTE_U);
153 e->env_tf = *tf;
154 e->env_tf.tf_cs = GD_UT | 3;
155 e->env_tf.tf_eflags |= FL_IF;
156 return 0;
不过在测试的时候一直出现了open()->ipv_send()->sys_page_map()->envid2env()这个函数的权限检查错误。发现这个函数里限定了只有父子关系的进程才能发生ipc 囧。。。
因此我不得不dirty hack了envid2env()中代码,以便让所有进程都能和fs_fs这个进程进行ipc通讯:
102 if (checkperm && e != curenv && e->env_parent_id != curenv->env_id) {
103 if ((e->env_type != ENV_TYPE_FS) && (curenv->env_type != EN V_TYPE_FS)) { // dirty hack to help fsipc between fs and othe r user env.
104 *env_store = 0;
105 return -E_BAD_ENV;
106 }
107 }
- Jos-lab5 (上)
- Jos-lab5 (下)
- MIT 操作系统实验 MIT JOS lab5
- Jos-Lab1 (上)
- jos
- Lab5 bootloader
- ucore lab5
- ucore lab5
- lab5 shellLabNote
- JOS开始
- Jos-hw4
- Jos-hw5
- Jos HW7
- 重温JOS
- JOS-lab4
- 操作系统实验报告 lab5
- OOAD Lab5实验文档
- csapp-lab5 shell-lab
- u-boot移植重要问题说明
- SQL2005 分五个版本区别详解
- 【二胡】古人诉离殇《江山此夜》艺术家:河图
- Windows消息大全——十进制版
- Effective C++读书笔记(6)
- Jos-lab5 (上)
- Centos6.4 vpn 服务端 搭建方法
- MSSQL跨服務器觸發器報錯的問題解決
- 并行逻辑回归
- SVN服务器搭建和使用(一)
- Ibatis实现动态分页分析之一
- 简单的登录界面
- SVN服务器搭建和使用(二)
- java中的位运算