Skip to content
Snippets Groups Projects
Commit 692f4b8e authored by ja3-saxby's avatar ja3-saxby
Browse files

Modify parameter name file_name in process_execute()

Let's clarify this because variables should be named what they are:
The argument passed to `process_execute()` is NOT a filename --it is the entire command string used for executing the program, which includes the file name AND any of its arguments, thus this variable is renamed to reflect this.
Also added comment block clarifying this within process_execute()
parent 4dedf583
No related branches found
No related tags found
No related merge requests found
......@@ -21,25 +21,32 @@
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 from
FILENAME. The new thread may be scheduled (and may even exit)
/* Starts a new thread running a user program loaded by parsing
COMMAND. 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 *file_name)
process_execute (const char *command)
{
char *fn_copy;
tid_t tid;
/* Make a copy of FILE_NAME.
/* Make a copy of COMMAND.
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, file_name, PGSIZE);
/* Create a new thread to execute FILE_NAME. */
tid = thread_create (file_name, PRI_DEFAULT, start_process, fn_copy);
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);
if (tid == TID_ERROR)
palloc_free_page (fn_copy);
......
......@@ -3,7 +3,7 @@
#include "threads/thread.h"
tid_t process_execute (const char *file_name);
tid_t process_execute (const char *command);
int process_wait (tid_t);
void process_exit (void);
void process_activate (void);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment