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 120 additions and 100 deletions
Showing only changes of commit 5ed999bc9c - Show all commits

View File

@@ -60,16 +60,9 @@ process_execute (const char *file_name)
return tid; return tid;
} }
static void *
push_to_stack (void **esp, void *data, size_t data_size)
{
*esp -= data_size;
memcpy (*esp, data, data_size);
return *esp;
}
static void process_init_stack (void *file_name_, char *saveptr, void **esp, static void process_init_stack (void *file_name_, char *saveptr, void **esp,
char *file_name); char *file_name);
static void *push_to_stack (void **esp, void *data, size_t data_size);
/* A thread function that loads a user process and starts it /* A thread function that loads a user process and starts it
running. */ running. */
@@ -205,6 +198,17 @@ process_init_stack (void *file_name_, char *saveptr, void **esp,
*(char *) *esp = 0; *(char *) *esp = 0;
} }
/* Helper function that pushes the first 'data_size' bytes stored in the
address '*data' into the stack given a pointer to the stack pointer
'**esp'. */
static void *
push_to_stack (void **esp, void *data, size_t data_size)
{
*esp -= data_size;
memcpy (*esp, data, data_size);
return *esp;
}
/* Waits for thread TID to die and returns its exit status. /* Waits for thread TID to die and returns its exit status.
* If it was terminated by the kernel (i.e. killed due to an exception), * If it was terminated by the kernel (i.e. killed due to an exception),
* returns -1. * returns -1.