From 9ae950fe9e1b3a96cbc507ace51c98e0a91a3ff5 Mon Sep 17 00:00:00 2001 From: Joshua Saxby <joshua.a.saxby@gmail.com> Date: Sat, 30 Nov 2019 08:01:42 +0000 Subject: [PATCH] Revert "Modify parameter name file_name in process_execute()" This reverts commit 692f4b8eadbc463795fb2c88d27b0965321ece7e. --- userprog/process.c | 23 ++++++++--------------- userprog/process.h | 2 +- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/userprog/process.c b/userprog/process.c index 5cf724a..1f6f72a 100644 --- a/userprog/process.c +++ b/userprog/process.c @@ -21,32 +21,25 @@ static thread_func start_process NO_RETURN; static bool load (const char *cmdline, void (**eip) (void), void **esp); -/* Starts a new thread running a user program loaded by parsing - COMMAND. The new thread may be scheduled (and may even exit) +/* Starts a new thread running a user program loaded from + FILENAME. The new thread may be scheduled (and may even exit) before process_execute() returns. Returns the new process's thread id, or TID_ERROR if the thread cannot be created. */ tid_t -process_execute (const char *command) +process_execute (const char *file_name) { char *fn_copy; tid_t tid; - /* Make a copy of COMMAND. + /* Make a copy of FILE_NAME. Otherwise there's a race between the caller and load(). */ fn_copy = palloc_get_page (0); if (fn_copy == NULL) return TID_ERROR; - strlcpy (fn_copy, command, PGSIZE); - - /* Create a new thread to execute COMMAND. */ - /* - * FIXME: right now, COMMAND is assumed to be just the filename on its own - * - * If this is not the case (if the user passed a program name with arguments), - * then loading will fail. - * NOTE: remove this comment block when argument parsing is implemented. - */ - tid = thread_create (command, PRI_DEFAULT, start_process, fn_copy); + strlcpy (fn_copy, file_name, PGSIZE); + + /* Create a new thread to execute FILE_NAME. */ + tid = thread_create (file_name, PRI_DEFAULT, start_process, fn_copy); if (tid == TID_ERROR) palloc_free_page (fn_copy); diff --git a/userprog/process.h b/userprog/process.h index ad49fec..688cd2a 100644 --- a/userprog/process.h +++ b/userprog/process.h @@ -3,7 +3,7 @@ #include "threads/thread.h" -tid_t process_execute (const char *command); +tid_t process_execute (const char *file_name); int process_wait (tid_t); void process_exit (void); void process_activate (void); -- GitLab