X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=solutions%2Fp2.patch;h=00711a2a484aead2743ddcb81a6cd0bd7e86167d;hb=58ff179ed68e25b33037ca479b0f51f8fdbec7fe;hp=0632ffaeb1ce5856cfc3b81df8db252b1b779472;hpb=226119d857608d2687bcbdd9d401b5d04a1970fb;p=pintos-anon diff --git a/solutions/p2.patch b/solutions/p2.patch index 0632ffa..00711a2 100644 --- a/solutions/p2.patch +++ b/solutions/p2.patch @@ -95,9 +95,9 @@ diff -u src/threads/thread.h~ src/threads/thread.h + struct semaphore dead; /* 1=child alive, 0=child dead. */ + }; + - void thread_init (void); - void thread_start (void); - void thread_tick (void); + /* If false (default), use round-robin scheduler. + If true, use multi-level feedback queue scheduler. + Controlled by kernel command-line options "-o mlfqs". Index: src/userprog/exception.c diff -u src/userprog/exception.c~ src/userprog/exception.c --- src/userprog/exception.c~ @@ -129,12 +129,12 @@ diff -u src/userprog/process.c~ src/userprog/process.c #include "threads/thread.h" #include "threads/vaddr.h" - static thread_func execute_thread NO_RETURN; + static thread_func start_process NO_RETURN; -static bool load (const char *cmdline, void (**eip) (void), void **esp); +static bool load (const char *cmd_line, void (**eip) (void), void **esp); + +/* Data structure shared between process_execute() in the -+ invoking thread and execute_thread() in the newly invoked ++ invoking thread and start_process() in the newly invoked + thread. */ +struct exec_info + { @@ -167,12 +167,12 @@ diff -u src/userprog/process.c~ src/userprog/process.c + sema_init (&exec.load_done, 0); /* Create a new thread to execute FILE_NAME. */ -- tid = thread_create (file_name, PRI_DEFAULT, execute_thread, fn_copy); +- tid = thread_create (file_name, PRI_DEFAULT, start_process, fn_copy); - if (tid == TID_ERROR) - palloc_free_page (fn_copy); + strlcpy (thread_name, file_name, sizeof thread_name); + strtok_r (thread_name, " ", &save_ptr); -+ tid = thread_create (thread_name, PRI_DEFAULT, execute_thread, &exec); ++ tid = thread_create (thread_name, PRI_DEFAULT, start_process, &exec); + if (tid != TID_ERROR) + { + sema_down (&exec.load_done); @@ -188,15 +188,15 @@ diff -u src/userprog/process.c~ src/userprog/process.c /* A thread function that loads a user process and starts it running. */ static void --execute_thread (void *file_name_) -+execute_thread (void *exec_) +-start_process (void *file_name_) ++start_process (void *exec_) { - char *file_name = file_name_; + struct exec_info *exec = exec_; struct intr_frame if_; bool success; -@@ -58,10 +78,29 @@ execute_thread (void *file_name_) +@@ -58,10 +78,29 @@ start_process (void *file_name_) if_.gs = if_.fs = if_.es = if_.ds = if_.ss = SEL_UDSEG; if_.cs = SEL_UCSEG; if_.eflags = FLAG_IF | FLAG_MBS; @@ -229,7 +229,7 @@ diff -u src/userprog/process.c~ src/userprog/process.c if (!success) thread_exit (); -@@ -75,18 +113,47 @@ execute_thread (void *file_name_) +@@ -75,18 +113,47 @@ start_process (void *file_name_) NOT_REACHED (); } @@ -493,7 +493,7 @@ Index: src/userprog/syscall.c diff -u src/userprog/syscall.c~ src/userprog/syscall.c --- src/userprog/syscall.c~ +++ src/userprog/syscall.c -@@ -1,20 +1,483 @@ +@@ -1,20 +1,486 @@ #include "userprog/syscall.h" #include +#include @@ -657,7 +657,10 @@ diff -u src/userprog/syscall.c~ src/userprog/syscall.c + for (length = 0; length < PGSIZE; length++) + { + if (us >= (char *) PHYS_BASE || !get_user (ks + length, us++)) -+ thread_exit (); ++ { ++ palloc_free_page (ks); ++ thread_exit (); ++ } + + if (ks[length] == '\0') + return ks;