您的位置:首页 > 其它

Jos-lab5 (下)

2014-02-23 22:49 351 查看
Exercise 4. Change
duppage
in lib/fork.c to follow the new convention. If the page table entry has the
PTE_SHARE
bit set, just copy the mapping directly. (You should use
PTE_SYSCALL
, not
0xfff
, to mask out the relevant bits from the page table entry.
0xfff
picks up the accessed and dirty bits as well.)

Likewise, implement
copy_shared_pages
inlib/spawn.c. It should loop through all page tableentries in the current process (just like
fork
did), copying any page mappings that have the
PTE_SHARE
bit set into the
child process.

@@ -69,7 +69,11 @@ duppage(envid_t envid, unsigned pn)

        void *addr = (void *)(pn * PGSIZE);

        pte_t pte = uvpt[PGNUM(addr)];

 

-       if ((pte & PTE_W) > 0 || (pte & PTE_COW) > 0) {

+       // LAB 5: Jacky 140223

+       if ((pte & PTE_SHARE) > 0) {

+               if ((r = sys_page_map(0, addr, envid, addr, (pte & PTE_SYSCALL))) < 0)

+                       panic("%s,%d failed: %e\n",__func__,__LINE__,r);

+       } else if ((pte & PTE_W) > 0 || (pte & PTE_COW) > 0) {

 copy_shared_pages(envid_t child)

 {

        // LAB 5: Your code here.

+       struct Env *env;

+       int r, i;

+//     if ((r = envid2env(child, &env, 1)) < 0)

+//             panic("%s() %d failed: %e\n",__func__,__LINE__,r);

+       for (i = 0; i < UTOP; i += PGSIZE) {

+               if ((uvpd[PDX(i)] & PTE_P) && (uvpt[PGNUM(i)] & PTE_P) && ((uvpt[PGNUM(i)

+                       if ((r = sys_page_map(0, (void *)i, child, (void *)i, (uvpt[PGNUM

+                               return r;

+               }

+       }

Exercise 5. In your kern/trap.c, call
kbd_intr
to handle trap
IRQ_OFFSET+IRQ_KBD
and
serial_intr
to handle trap
IRQ_OFFSET+IRQ_SERIAL
.

+       // Handle keyboard and serial interrupts.

+       // LAB 5: Your code here.

+               case IRQ_OFFSET + IRQ_KBD:

+                       kbd_intr();

+                       return;

+               case IRQ_OFFSET + IRQ_SERIAL:

+                       serial_intr();

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