feat: initial shared file page management and initialization

This commit is contained in:
2024-12-05 21:46:49 +00:00
parent 4dd6b6e928
commit dd46200256
5 changed files with 192 additions and 8 deletions

View File

@@ -292,6 +292,7 @@ fetch_page (void *upage, bool write)
switch (page->type) {
case PAGE_MMAP:
case PAGE_FILE:
case PAGE_SHARED:
success = page_load_file (page);
if (success && page->type == PAGE_FILE)
{

View File

@@ -2,9 +2,12 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include "devices/swap.h"
#include "threads/init.h"
#include "threads/pte.h"
#include "threads/palloc.h"
#include "vm/frame.h"
#include "vm/page.h"
static uint32_t *active_pd (void);
@@ -39,8 +42,14 @@ pagedir_destroy (uint32_t *pd)
uint32_t *pte;
for (pte = pt; pte < pt + PGSIZE / sizeof *pte; pte++)
if (*pte & PTE_P)
palloc_free_page (pte_get_page (*pte));
{
if (page_is_shared_pte (pte))
continue;
if (page_in_swap_pte (pte))
swap_drop (page_get_swap_pte (pte));
if (*pte & PTE_P)
frame_free (pte_get_page (*pte));
}
palloc_free_page (pt);
}
palloc_free_page (pd);