X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=solutions%2Fp3.patch;h=d3a5ddee4b8075905b2c477bebb86a649dce6986;hb=45716d7c0001861ebf8848217cdc446c4ba2c47a;hp=6bc703b5b1043ccbc309d66dcf8529b326f002d1;hpb=fc7845f7a47c461f49b8ee956be2d77e41e09320;p=pintos-anon diff --git a/solutions/p3.patch b/solutions/p3.patch index 6bc703b..d3a5dde 100644 --- a/solutions/p3.patch +++ b/solutions/p3.patch @@ -1685,7 +1685,7 @@ diff -u src/vm/page.c~ src/vm/page.c + return false; + + /* Copy data into the frame. */ -+ if (p->sector != (disk_sector_t) -1) ++ if (p->sector != (block_sector_t) -1) + { + /* Get data from swap. */ + swap_in (p); @@ -1823,7 +1823,7 @@ diff -u src/vm/page.c~ src/vm/page.c + + p->frame = NULL; + -+ p->sector = (disk_sector_t) -1; ++ p->sector = (block_sector_t) -1; + + p->file = NULL; + p->file_offset = 0; @@ -1916,7 +1916,7 @@ diff -u src/vm/page.h~ src/vm/page.h +#define VM_PAGE_H + +#include -+#include "devices/disk.h" ++#include "devices/block.h" +#include "filesys/off_t.h" +#include "threads/synch.h" + @@ -1936,7 +1936,7 @@ diff -u src/vm/page.h~ src/vm/page.h + struct frame *frame; /* Page frame. */ + + /* Swap information, protected by frame->frame_lock. */ -+ disk_sector_t sector; /* Starting sector of swap area, or -1. */ ++ block_sector_t sector; /* Starting sector of swap area, or -1. */ + + /* Memory-mapped file information, protected by frame->frame_lock. */ + bool private; /* False to write back to file, @@ -1973,12 +1973,11 @@ diff -u src/vm/swap.c~ src/vm/swap.c +#include +#include "vm/frame.h" +#include "vm/page.h" -+#include "devices/disk.h" +#include "threads/synch.h" +#include "threads/vaddr.h" + -+/* The swap disk. */ -+static struct disk *swap_disk; ++/* The swap device. */ ++static struct block *swap_device; + +/* Used swap pages. */ +static struct bitmap *swap_bitmap; @@ -1987,20 +1986,21 @@ diff -u src/vm/swap.c~ src/vm/swap.c +static struct lock swap_lock; + +/* Number of sectors per page. */ -+#define PAGE_SECTORS (PGSIZE / DISK_SECTOR_SIZE) ++#define PAGE_SECTORS (PGSIZE / BLOCK_SECTOR_SIZE) + +/* Sets up swap. */ +void +swap_init (void) +{ -+ swap_disk = disk_get (1, 1); -+ if (swap_disk == NULL) ++ swap_device = block_get_role (BLOCK_SWAP); ++ if (swap_device == NULL) + { -+ printf ("no swap disk--swap disabled\n"); ++ printf ("no swap device--swap disabled\n"); + swap_bitmap = bitmap_create (0); + } + else -+ swap_bitmap = bitmap_create (disk_size (swap_disk) / PAGE_SECTORS); ++ swap_bitmap = bitmap_create (block_size (swap_device) ++ / PAGE_SECTORS); + if (swap_bitmap == NULL) + PANIC ("couldn't create swap bitmap"); + lock_init (&swap_lock); @@ -2015,13 +2015,13 @@ diff -u src/vm/swap.c~ src/vm/swap.c + + ASSERT (p->frame != NULL); + ASSERT (lock_held_by_current_thread (&p->frame->lock)); -+ ASSERT (p->sector != (disk_sector_t) -1); ++ ASSERT (p->sector != (block_sector_t) -1); + + for (i = 0; i < PAGE_SECTORS; i++) -+ disk_read (swap_disk, p->sector + i, -+ p->frame->base + i * DISK_SECTOR_SIZE); ++ block_read (swap_device, p->sector + i, ++ p->frame->base + i * BLOCK_SECTOR_SIZE); + bitmap_reset (swap_bitmap, p->sector / PAGE_SECTORS); -+ p->sector = (disk_sector_t) -1; ++ p->sector = (block_sector_t) -1; +} + +/* Swaps out page P, which must have a locked frame. */ @@ -2042,8 +2042,8 @@ diff -u src/vm/swap.c~ src/vm/swap.c + + p->sector = slot * PAGE_SECTORS; + for (i = 0; i < PAGE_SECTORS; i++) -+ disk_write (swap_disk, p->sector + i, -+ p->frame->base + i * DISK_SECTOR_SIZE); ++ block_write (swap_device, p->sector + i, ++ p->frame->base + i * BLOCK_SECTOR_SIZE); + + p->private = false; + p->file = NULL;