-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
139 changed files
with
3,695 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
include ../Makefile.kernel | ||
all grade check: | ||
@echo "project 4 is not ready. Wait for the announcement." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef VM_ANON_H | ||
#define VM_ANON_H | ||
#include "vm/vm.h" | ||
struct page; | ||
enum vm_type; | ||
|
||
struct anon_page { | ||
}; | ||
|
||
void vm_anon_init (void); | ||
bool anon_initializer (struct page *page, enum vm_type type, void *kva); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef VM_FILE_H | ||
#define VM_FILE_H | ||
#include "filesys/file.h" | ||
#include "vm/vm.h" | ||
|
||
struct page; | ||
enum vm_type; | ||
|
||
struct file_page { | ||
}; | ||
|
||
void vm_file_init (void); | ||
bool file_map_initializer (struct page *page, enum vm_type type, void *kva); | ||
void *do_mmap(void *addr, size_t length, int writable, | ||
struct file *file, off_t offset); | ||
void do_munmap (void *va); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#ifndef _VM_INSPECT_H_ | ||
#define _VM_INSPECT_H_ | ||
void register_inspect_intr (void); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef VM_UNINIT_H | ||
#define VM_UNINIT_H | ||
#include "vm/vm.h" | ||
|
||
struct page; | ||
enum vm_type; | ||
|
||
typedef bool vm_initializer (struct page *, void *aux); | ||
|
||
/* Uninitlialized page. The type for implementing the | ||
* "Lazy loading". */ | ||
struct uninit_page { | ||
/* Initiate the contets of the page */ | ||
vm_initializer *init; | ||
enum vm_type type; | ||
void *aux; | ||
/* Initiate the struct page and maps the pa to the va */ | ||
bool (*page_initializer) (struct page *, enum vm_type, void *kva); | ||
}; | ||
|
||
void uninit_new (struct page *page, void *va, vm_initializer *init, | ||
enum vm_type type, void *aux, | ||
bool (*initializer)(struct page *, enum vm_type, void *kva)); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#ifndef VM_VM_H | ||
#define VM_VM_H | ||
#include <stdbool.h> | ||
#include "threads/palloc.h" | ||
|
||
enum vm_type { | ||
/* page not initialized */ | ||
VM_UNINIT = 0, | ||
/* page not related to the file, aka anonymous page */ | ||
VM_ANON = 1, | ||
/* page that realated to the file */ | ||
VM_FILE = 2, | ||
/* page that hold the page cache, for project 4 */ | ||
VM_PAGE_CACHE = 3, | ||
|
||
/* Bit flags to store state */ | ||
|
||
/* Auxillary bit flag marker for store information. You can add more | ||
* markers, until the value is fit in the int. */ | ||
VM_MARKER_0 = (1 << 3), | ||
VM_MARKER_1 = (1 << 4), | ||
|
||
/* DO NOT EXCEED THIS VALUE. */ | ||
VM_MARKER_END = (1 << 31), | ||
}; | ||
|
||
#include "vm/uninit.h" | ||
#include "vm/anon.h" | ||
#include "vm/file.h" | ||
|
||
struct page_operations; | ||
struct thread; | ||
|
||
#define VM_TYPE(type) ((type) & 7) | ||
|
||
/* The representation of "page". | ||
* This is kind of "parent class", which has four "child class"es, which are | ||
* uninit_page, file_page, anon_page, and page cache (project4). | ||
* DO NOT REMOVE/MODIFY PREDEFINED MEMBER OF THIS STRUCTURE. */ | ||
struct page { | ||
const struct page_operations *operations; | ||
void *va; /* Address in terms of user space */ | ||
struct frame *frame; /* Back reference for frame */ | ||
|
||
/* Your implementation */ | ||
|
||
/* Per-type data are binded into the union. | ||
* Each function automatically detects the current union */ | ||
union { | ||
struct uninit_page uninit; | ||
struct anon_page anon; | ||
struct file_page file; | ||
#ifdef EFILESYS | ||
struct page_cache page_cache; | ||
#endif | ||
}; | ||
}; | ||
|
||
/* The representation of "frame" */ | ||
struct frame { | ||
void *kva; | ||
struct page *page; | ||
}; | ||
|
||
/* The function table for page operations. | ||
* This is one way of implementing "interface" in C. | ||
* Put the table of "method" into the struct's member, and | ||
* call it whenever you needed. */ | ||
struct page_operations { | ||
bool (*swap_in) (struct page *, void *); | ||
bool (*swap_out) (struct page *); | ||
void (*destroy) (struct page *); | ||
enum vm_type type; | ||
}; | ||
|
||
#define swap_in(page, v) (page)->operations->swap_in ((page), v) | ||
#define swap_out(page) (page)->operations->swap_out (page) | ||
#define destroy(page) \ | ||
if ((page)->operations->destroy) (page)->operations->destroy (page) | ||
|
||
/* Representation of current process's memory space. | ||
* We don't want to force you to obey any specific design for this struct. | ||
* All designs up to you for this. */ | ||
struct supplemental_page_table { | ||
}; | ||
|
||
#include "threads/thread.h" | ||
void supplemental_page_table_init (struct supplemental_page_table *spt); | ||
bool supplemental_page_table_copy (struct supplemental_page_table *dst, | ||
struct supplemental_page_table *src); | ||
void supplemental_page_table_kill (struct supplemental_page_table *spt); | ||
struct page *spt_find_page (struct supplemental_page_table *spt, | ||
void *va); | ||
bool spt_insert_page (struct supplemental_page_table *spt, struct page *page); | ||
void spt_remove_page (struct supplemental_page_table *spt, struct page *page); | ||
|
||
void vm_init (void); | ||
bool vm_try_handle_fault (struct intr_frame *f, void *addr, bool user, | ||
bool write, bool not_present); | ||
|
||
#define vm_alloc_page(type, upage, writable) \ | ||
vm_alloc_page_with_initializer ((type), (upage), (writable), NULL, NULL) | ||
bool vm_alloc_page_with_initializer (enum vm_type type, void *upage, | ||
bool writable, vm_initializer *init, void *aux); | ||
void vm_dealloc_page (struct page *page); | ||
bool vm_claim_page (void *va); | ||
enum vm_type page_get_type (struct page *page); | ||
|
||
#endif /* VM_VM_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
#include "tests/lib.h" | ||
|
||
const char *test_name = "child-simple"; | ||
|
||
int | ||
main (void) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Percentage of the testing point total designated for each set of | ||
# tests. | ||
|
||
# This project is primarily about virtual memory, but all the previous | ||
# functionality should work too | ||
|
||
1% tests/threads/Rubric.alarm | ||
1% tests/threads/Rubric.priority | ||
8% tests/userprog/Rubric.functionality | ||
5% tests/userprog/Rubric.robustness | ||
|
||
55% tests/vm/Rubric.functionality | ||
25% tests/vm/Rubric.robustness | ||
5% tests/filesys/base/Rubric | ||
|
||
# Extra project | ||
25% tests/vm/cow/Rubric |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Percentage of the testing point total designated for each set of | ||
# tests. | ||
|
||
# This project is primarily about virtual memory, but all the previous | ||
# functionality should work too | ||
|
||
2% tests/threads/Rubric.alarm | ||
3% tests/threads/Rubric.priority | ||
2% tests/userprog/Rubric.functionality | ||
3% tests/userprog/Rubric.robustness | ||
|
||
50% tests/vm/Rubric.functionality | ||
20% tests/vm/Rubric.robustness | ||
20% tests/filesys/base/Rubric | ||
|
||
# Extra project | ||
10% tests/vm/cow/Rubric |
Oops, something went wrong.