From bae02aee5ad41b13a08170fc257b5ac360ae2d8a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 19 Jan 2005 23:00:07 +0000 Subject: [PATCH] Fix race condition in process loading. --- solutions/p2.patch | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/solutions/p2.patch b/solutions/p2.patch index 70e5dbe..578ff5e 100644 --- a/solutions/p2.patch +++ b/solutions/p2.patch @@ -293,7 +293,7 @@ diff -u -p -r1.6 process.c /* Starts a new thread running a user program loaded from FILENAME. The new thread may be scheduled before -@@ -26,31 +36,31 @@ static bool load (const char *cmdline, v +@@ -26,31 +36,32 @@ static bool load (const char *cmdline, v tid_t process_execute (const char *filename) { @@ -334,7 +334,7 @@ diff -u -p -r1.6 process.c - char *filename = filename_; + struct exec_info *exec = exec_; struct intr_frame if_; -- bool success; + bool success; /* Initialize interrupt frame and load executable. */ memset (&if_, 0, sizeof if_); @@ -346,10 +346,9 @@ diff -u -p -r1.6 process.c - - /* If load failed, quit. */ - palloc_free_page (filename); -- if (!success) -+ exec->success = load (exec->filename, &if_.eip, &if_.esp); ++ success = exec->success = load (exec->filename, &if_.eip, &if_.esp); + sema_up (&exec->load_done); -+ if (!exec->success) + if (!success) thread_exit (); /* Switch page tables. */ -- 2.30.2