Implement Supplemental Page Table (SPT) per thread along with structure for its entries, w/ G

This commit is contained in:
sBubshait
2024-11-28 17:54:15 +00:00
parent 1e6b90da0d
commit 14fc96febf
4 changed files with 49 additions and 3 deletions

View File

@@ -2,6 +2,29 @@
#define VM_PAGE_H
#include "threads/thread.h"
#include "filesys/off_t.h"
enum page_type {
PAGE_EXECUTABLE,
PAGE_EMPTY
};
struct page_entry {
enum page_type type; /* Type of Data that should go into the page */
void *upage; /* Start Address of the User Page (Key of hash table). */
/* File Data */
struct file *file; /* Pointer to the file for executables. */
off_t offset; /* Offset of the page content within the file. */
uint32_t read_bytes; /* Number of bytes to read within the page. */
uint32_t zero_bytes; /* Number of bytes to zero within the page. */
bool writable; /* Flag for whether this page is writable or not. */
struct hash_elem elem; /* An elem for the hash table. */
};
unsigned page_hash (const struct hash_elem *e, void *aux);
bool page_less (const struct hash_elem *a_, const struct hash_elem *b_, void *aux);
void page_set_swap (struct thread *, void *, size_t);
size_t page_get_swap (struct thread *, void *);