summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--proj2.txt44
-rw-r--r--vm/mmap.c2
-rw-r--r--vm/mmap.h4
-rw-r--r--vm/page.c2
-rw-r--r--vm/page.h2
5 files changed, 25 insertions, 29 deletions
diff --git a/proj2.txt b/proj2.txt
index 3b89826..8dd36f2 100644
--- a/proj2.txt
+++ b/proj2.txt
@@ -30,13 +30,12 @@ Manuel Mausz <manuel-uni@mausz.at>
30>> enumeration. Identify the purpose of each in 25 words or less. 30>> enumeration. Identify the purpose of each in 25 words or less.
31 31
32struct thread: 32struct thread:
33 struct hash page_table ...supplemental page table of thread 33 struct hash page_table ...supplemental page table of thread
34 34
35struct page_table_entry: 35struct page_table_entry:
36 void *upage ...virtual address of page 36 void *upage ...virtual address of page
37 bool loaded ...indicates if page is loaded 37 bool loaded ...indicates if page is loaded
38 enum type ...type of page 38 struct segment ...structure needed for lazy loading of data segments
39 union struct segment ...structure needed for lazy loading of data segments
40 struct hash_elem elem ...Hash element. 39 struct hash_elem elem ...Hash element.
41 40
42---- IMPLEMENTATION ---- 41---- IMPLEMENTATION ----
@@ -44,28 +43,25 @@ struct page_table_entry:
44>> determine the file and file offset corresponding to a virtual 43>> determine the file and file offset corresponding to a virtual
45>> address? 44>> address?
46 45
47When we try to insert a new segment into our supplemental page table we record some information in the struct segment of each page table entry. This struct contains 46When we try to insert a new segment into our supplemental page table we record
48 47some information in the struct segment of each page table entry.
49-) the virtual address of the page 48This struct contains:
50-) the type of the page table entry, weather it is an ordinary segment or a 49* the virtual address of the page
51memory mapped file page 50* if the page is already loaded or not
52-) if the page is already loaded or not (per default false) 51* the associated file
53-) the file the page corresponds to 52* the offset in the file
54-) the offset in the file 53* if the page is writable or not
55-) if the page is writable or not
56 54
57Lazy loading of pages is accomplished by not loading the page instantly. The 55Lazy loading of pages is accomplished by not loading the page instantly. The
58actual page-loading is done when a page-fault occurs. 56actual page-loading is done when a page-fault occurs.
59 57
60
61---- SYNCHRONIZATION ---- 58---- SYNCHRONIZATION ----
62>> A3: How do you deal with or prevent page faults in file system 59>> A3: How do you deal with or prevent page faults in file system
63>> routines. Argue why your solution is deadlock free. 60>> routines. Argue why your solution is deadlock free.
64 61
65As we do not have any global structures, that means they are per process and 62As we do not have any global structures, that means they are per process and
66per thread, page faults can not happen, the same argument goes for the 63per thread, page faults can not happen. The same argument goes for the
67question of being deadlock free. File-structures are per process too, so only 64question of being deadlock free.
68one process can deal with a file at once.
69 65
70 STACK GROWTH 66 STACK GROWTH
71 ============ 67 ============
@@ -83,9 +79,10 @@ extern void *syscall_sp ...stored stack pointer for the "page fault inside
83>> B2: Describe how you integrated the (potentially growing) stack segment 79>> B2: Describe how you integrated the (potentially growing) stack segment
84>> into your page table management implementation. 80>> into your page table management implementation.
85 81
86The Stack growth itself is implemented in the page fault handler. The page 82The stack growth itself gets triggered by the page fault handler just as the
87table is just needed to allocate a new page for the stack when it needs to 83lazy loading of pages. Other than that there's no association between the pages
88grow. 84of the stack and the pages of segments/mmapped files.
85So pages of the stack don't get tracked inside the page table at all!
89 86
90---- ALGORITHMS ---- 87---- ALGORITHMS ----
91>> B3: Explain how you detect a page fault which should trigger a 88>> B3: Explain how you detect a page fault which should trigger a
@@ -93,11 +90,10 @@ grow.
93>> to work? 90>> to work?
94 91
95If we do not find a valid entry in our supplemental page-table it could be 92If we do not find a valid entry in our supplemental page-table it could be
96very well be a valid stack access. The maximum offset we consider as a valid 93very well be a valid stack access. The maximum offset we consider a valid
97access is due to the PUSHA instruction, which can try to access an address 32 94access is caused by the PUSHA instruction, which may try to access an address
98bytes below the current stack pointer. If this is the case we try to grow the 9532 bytes below the current stack pointer. Everthing higher we consider
99stack by one page. 96an exception.
100
101 97
102 MEMORY MAPPED FILES 98 MEMORY MAPPED FILES
103 =================== 99 ===================
diff --git a/vm/mmap.c b/vm/mmap.c
index 55ee91b..0dc9190 100644
--- a/vm/mmap.c
+++ b/vm/mmap.c
@@ -38,7 +38,7 @@ mmap_table_free (struct mmap_table *table)
38/* inserts a new mmap entry in the mmap table. 38/* inserts a new mmap entry in the mmap table.
39 returns -1 if entry is invalid or already in the table */ 39 returns -1 if entry is invalid or already in the table */
40mapid_t 40mapid_t
41mmap_table_insert (struct mmap_table *table, uint8_t *upage, struct file *file, 41mmap_table_insert (struct mmap_table *table, void *upage, struct file *file,
42 off_t len) 42 off_t len)
43{ 43{
44 off_t ofs = 0; 44 off_t ofs = 0;
diff --git a/vm/mmap.h b/vm/mmap.h
index 09276a7..159e61a 100644
--- a/vm/mmap.h
+++ b/vm/mmap.h
@@ -18,14 +18,14 @@ struct mmap_table
18/* a single entry in the mmap table */ 18/* a single entry in the mmap table */
19struct mmap_table_entry 19struct mmap_table_entry
20{ 20{
21 uint8_t *upage; /* virtual address of first page of mmapped file */ 21 void *upage; /* virtual address of first page of mmapped file */
22 struct file *file; /* file handle */ 22 struct file *file; /* file handle */
23 int pages; /* number of pages the mapping needs */ 23 int pages; /* number of pages the mapping needs */
24}; 24};
25 25
26bool mmap_table_init (struct mmap_table *table); 26bool mmap_table_init (struct mmap_table *table);
27void mmap_table_free (struct mmap_table *table); 27void mmap_table_free (struct mmap_table *table);
28mapid_t mmap_table_insert (struct mmap_table *table, uint8_t *upage, 28mapid_t mmap_table_insert (struct mmap_table *table, void *upage,
29 struct file *file, off_t len); 29 struct file *file, off_t len);
30bool mmap_table_remove (struct mmap_table *table, mapid_t mapping); 30bool mmap_table_remove (struct mmap_table *table, mapid_t mapping);
31 31
diff --git a/vm/page.c b/vm/page.c
index 98120e5..b40382f 100644
--- a/vm/page.c
+++ b/vm/page.c
@@ -69,7 +69,7 @@ page_table_insert (struct hash *ht, struct page_table_entry *pte)
69 returns false if entry is invalid or already in the table */ 69 returns false if entry is invalid or already in the table */
70bool 70bool
71page_table_insert_segment (struct hash *ht, struct file *file, off_t ofs, 71page_table_insert_segment (struct hash *ht, struct file *file, off_t ofs,
72 uint8_t *upage, uint32_t read_bytes, bool writable) 72 void *upage, uint32_t read_bytes, bool writable)
73{ 73{
74 struct page_table_entry *pte = malloc (sizeof *pte); 74 struct page_table_entry *pte = malloc (sizeof *pte);
75 if (pte == NULL) 75 if (pte == NULL)
diff --git a/vm/page.h b/vm/page.h
index c78ab65..b7997fe 100644
--- a/vm/page.h
+++ b/vm/page.h
@@ -28,7 +28,7 @@ void page_table_free (struct hash *ht);
28struct page_table_entry *page_table_fetch (struct hash *ht, void *upage); 28struct page_table_entry *page_table_fetch (struct hash *ht, void *upage);
29struct page_table_entry *page_table_remove (struct hash *ht, void *upage); 29struct page_table_entry *page_table_remove (struct hash *ht, void *upage);
30bool page_table_insert_segment (struct hash *ht, struct file *file, off_t ofs, 30bool page_table_insert_segment (struct hash *ht, struct file *file, off_t ofs,
31 uint8_t *upage, uint32_t read_bytes, bool writable); 31 void *upage, uint32_t read_bytes, bool writable);
32bool page_load (struct page_table_entry *pte); 32bool page_load (struct page_table_entry *pte);
33 33
34#endif 34#endif