From ab716de0a6ed8dcb7b2f880dd3466d14fd727c11 Mon Sep 17 00:00:00 2001 From: sBubshait Date: Wed, 6 Nov 2024 15:46:47 +0000 Subject: [PATCH 1/2] Update process_wait to temporarily sleep for 1 second to allow user programs to run --- src/userprog/process.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/userprog/process.c b/src/userprog/process.c index 49b9bd5..017e14b 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -17,6 +17,7 @@ #include "threads/palloc.h" #include "threads/thread.h" #include "threads/vaddr.h" +#include "devices/timer.h" static thread_func start_process NO_RETURN; static bool load (const char *cmdline, void (**eip) (void), void **esp); @@ -88,7 +89,12 @@ start_process (void *file_name_) int process_wait (tid_t child_tid UNUSED) { - return -1; + /* As a temporary wait, waiting will just put the thread to sleep for one + second (TIMER_FREQ = 100 ticks ~ 1 second). */ + /* TODO: Implement process_wait () correctly. Remove the next line. */ + timer_sleep (TIMER_FREQ); + + return 0; /* TODO: Change this too */ } /* Free the current process's resources. */ -- 2.49.1 From fcb7e9e4414d320bef117be95326c81f69d35b98 Mon Sep 17 00:00:00 2001 From: sBubshait Date: Wed, 6 Nov 2024 15:48:27 +0000 Subject: [PATCH 2/2] Update setup_stack to temporarily fake set-up for a stack to prevent page faults in no arg user programs --- src/userprog/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/userprog/process.c b/src/userprog/process.c index 017e14b..cde4b4a 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -457,7 +457,7 @@ setup_stack (void **esp) { success = install_page (((uint8_t *) PHYS_BASE) - PGSIZE, kpage, true); if (success) - *esp = PHYS_BASE; + *esp = PHYS_BASE - 12; else palloc_free_page (kpage); } -- 2.49.1