Implement complete stack initialization, process_wait, and all system calls correctly except exec #34

Merged
td1223 merged 46 commits from userprog-merge into master 2024-11-11 22:56:29 +00:00
4 changed files with 172 additions and 122 deletions
Showing only changes of commit 049fc5559c - Show all commits

View File

@@ -40,9 +40,9 @@ struct process_start_data
{ {
char *cmd; /* Pointer to a copy of the command used to execute the process. char *cmd; /* Pointer to a copy of the command used to execute the process.
Allocated a page that must be freed by process_start. */ Allocated a page that must be freed by process_start. */
char *cmd_saveptr; /* Value pointed to by 'saveptr' argument used by char *cmd_saveptr; /* Value pointed to by 'saveptr' argument used by
successive calls to strtok_r to split 'cmd' into successive calls to strtok_r to split 'cmd' into
tokens while maintaining state. */ tokens while maintaining state. */
char *file_name; /* Name of the file of the process to be started. */ char *file_name; /* Name of the file of the process to be started. */
}; };
@@ -88,7 +88,6 @@ process_execute (const char *cmd)
return tid; return tid;
} }
static bool install_page (void *upage, void *kpage, bool writable); static bool install_page (void *upage, void *kpage, bool writable);
static bool process_init_stack (char *cmd_saveptr, void **esp, char *file_name); static bool process_init_stack (char *cmd_saveptr, void **esp, char *file_name);
static void *push_to_stack (void **esp, void *data, size_t data_size); static void *push_to_stack (void **esp, void *data, size_t data_size);
@@ -231,8 +230,9 @@ process_init_stack (char *cmd_saveptr, void **esp, char *file_name)
return true; return true;
} }
/* Helper function that pushes the first 'data_size' bytes stored in the /* Helper function that pushes the first 'data_size' bytes stored
address '*data' into the stack given a pointer to the stack pointer '**esp'. */ in the address '*data' into the stack given a pointer to the
stack pointer '**esp'. */
static void * static void *
push_to_stack (void **esp, void *data, size_t data_size) push_to_stack (void **esp, void *data, size_t data_size)
{ {