projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement a proper block layer with partition support.
[pintos-anon]
/
solutions
/
p3.patch
diff --git
a/solutions/p3.patch
b/solutions/p3.patch
index 556be830ca39cc500cd027a2cb462a28b060a1a6..d3a5ddee4b8075905b2c477bebb86a649dce6986 100644
(file)
--- a/
solutions/p3.patch
+++ b/
solutions/p3.patch
@@
-106,7
+106,7
@@
diff -u src/threads/init.c~ src/threads/init.c
+#include "vm/swap.h"
/* Amount of physical memory, in 4 kB pages. */
+#include "vm/swap.h"
/* Amount of physical memory, in 4 kB pages. */
- size_t ram_pages;
+ size_t
init_
ram_pages;
@@ -124,6 +126,9 @@ main (void)
filesys_init (format_filesys);
#endif
@@ -124,6 +126,9 @@ main (void)
filesys_init (format_filesys);
#endif
@@
-318,7
+318,7
@@
diff -u src/userprog/pagedir.c~ src/userprog/pagedir.c
--- src/userprog/pagedir.c~
+++ src/userprog/pagedir.c
@@ -35,15 +35,7 @@ pagedir_destroy (uint32_t *pd)
--- src/userprog/pagedir.c~
+++ src/userprog/pagedir.c
@@ -35,15 +35,7 @@ pagedir_destroy (uint32_t *pd)
- ASSERT (pd !=
base
_page_dir);
+ ASSERT (pd !=
init
_page_dir);
for (pde = pd; pde < pd + pd_no (PHYS_BASE); pde++)
if (*pde & PTE_P)
- {
for (pde = pd; pde < pd + pd_no (PHYS_BASE); pde++)
if (*pde & PTE_P)
- {
@@
-809,10
+809,10
@@
diff -u src/userprog/syscall.c~ src/userprog/syscall.c
+#include "userprog/process.h"
+#include "userprog/pagedir.h"
+#include "devices/input.h"
+#include "userprog/process.h"
+#include "userprog/pagedir.h"
+#include "devices/input.h"
++#include "devices/shutdown.h"
+#include "filesys/directory.h"
+#include "filesys/filesys.h"
+#include "filesys/file.h"
+#include "filesys/directory.h"
+#include "filesys/filesys.h"
+#include "filesys/file.h"
-+#include "threads/init.h"
#include "threads/interrupt.h"
+#include "threads/malloc.h"
+#include "threads/palloc.h"
#include "threads/interrupt.h"
+#include "threads/malloc.h"
+#include "threads/palloc.h"
@@
-979,7
+979,7
@@
diff -u src/userprog/syscall.c~ src/userprog/syscall.c
+static int
+sys_halt (void)
+{
+static int
+sys_halt (void)
+{
-+ power_off ();
++
shutdown_
power_off ();
+}
+
+/* Exit system call. */
+}
+
+/* Exit system call. */
@@
-1443,7
+1443,7
@@
diff -u src/vm/frame.c~ src/vm/frame.c
+
+ lock_init (&scan_lock);
+
+
+ lock_init (&scan_lock);
+
-+ frames = malloc (sizeof *frames * ram_pages);
++ frames = malloc (sizeof *frames *
init_
ram_pages);
+ if (frames == NULL)
+ PANIC ("out of memory allocating page frames");
+
+ if (frames == NULL)
+ PANIC ("out of memory allocating page frames");
+
@@
-1685,7
+1685,7
@@
diff -u src/vm/page.c~ src/vm/page.c
+ return false;
+
+ /* Copy data into the frame. */
+ return false;
+
+ /* Copy data into the frame. */
-+ if (p->sector != (
dis
k_sector_t) -1)
++ if (p->sector != (
bloc
k_sector_t) -1)
+ {
+ /* Get data from swap. */
+ swap_in (p);
+ {
+ /* 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->frame = NULL;
+
-+ p->sector = (
dis
k_sector_t) -1;
++ p->sector = (
bloc
k_sector_t) -1;
+
+ p->file = NULL;
+ p->file_offset = 0;
+
+ 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 <hash.h>
+#define VM_PAGE_H
+
+#include <hash.h>
-+#include "devices/
dis
k.h"
++#include "devices/
bloc
k.h"
+#include "filesys/off_t.h"
+#include "threads/synch.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. */
+ struct frame *frame; /* Page frame. */
+
+ /* Swap information, protected by frame->frame_lock. */
-+
dis
k_sector_t sector; /* Starting sector of swap area, or -1. */
++
bloc
k_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,
+
+ /* 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 <stdio.h>
+#include "vm/frame.h"
+#include "vm/page.h"
+#include <stdio.h>
+#include "vm/frame.h"
+#include "vm/page.h"
-+#include "devices/disk.h"
+#include "threads/synch.h"
+#include "threads/vaddr.h"
+
+#include "threads/synch.h"
+#include "threads/vaddr.h"
+
-+/* The swap d
isk
. */
-+static struct
disk *swap_disk
;
++/* The swap d
evice
. */
++static struct
block *swap_device
;
+
+/* Used swap pages. */
+static struct bitmap *swap_bitmap;
+
+/* 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. */
+static struct lock swap_lock;
+
+/* Number of sectors per page. */
-+#define PAGE_SECTORS (PGSIZE /
DIS
K_SECTOR_SIZE)
++#define PAGE_SECTORS (PGSIZE /
BLOC
K_SECTOR_SIZE)
+
+/* Sets up swap. */
+void
+swap_init (void)
+{
+
+/* Sets up swap. */
+void
+swap_init (void)
+{
-+ swap_d
isk = disk_get (1, 1
);
-+ if (swap_d
isk
== NULL)
++ swap_d
evice = block_get_role (BLOCK_SWAP
);
++ if (swap_d
evice
== NULL)
+ {
+ {
-+ printf ("no swap d
isk
--swap disabled\n");
++ printf ("no swap d
evice
--swap disabled\n");
+ swap_bitmap = bitmap_create (0);
+ }
+ else
+ 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);
+ 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->frame != NULL);
+ ASSERT (lock_held_by_current_thread (&p->frame->lock));
-+ ASSERT (p->sector != (
dis
k_sector_t) -1);
++ ASSERT (p->sector != (
bloc
k_sector_t) -1);
+
+ for (i = 0; i < PAGE_SECTORS; i++)
+
+ for (i = 0; i < PAGE_SECTORS; i++)
-+
disk_read (swap_disk
, p->sector + i,
-+
p->frame->base + i * DIS
K_SECTOR_SIZE);
++
block_read (swap_device
, p->sector + i,
++
p->frame->base + i * BLOC
K_SECTOR_SIZE);
+ bitmap_reset (swap_bitmap, p->sector / PAGE_SECTORS);
+ bitmap_reset (swap_bitmap, p->sector / PAGE_SECTORS);
-+ p->sector = (
dis
k_sector_t) -1;
++ p->sector = (
bloc
k_sector_t) -1;
+}
+
+/* Swaps out page P, which must have a locked frame. */
+}
+
+/* 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++)
+
+ p->sector = slot * PAGE_SECTORS;
+ for (i = 0; i < PAGE_SECTORS; i++)
-+
disk_write (swap_disk
, p->sector + i,
-+
p->frame->base + i * DIS
K_SECTOR_SIZE);
++
block_write (swap_device
, p->sector + i,
++
p->frame->base + i * BLOC
K_SECTOR_SIZE);
+
+ p->private = false;
+ p->file = NULL;
+
+ p->private = false;
+ p->file = NULL;