Skip to content
Snippets Groups Projects
Commit b088432a authored by a2-stratford's avatar a2-stratford
Browse files

Basic fixes

parent 1d97a772
No related branches found
No related tags found
2 merge requests!22Merge Feature/system calls,!7Implemented the close system call
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
#include <stdint.h> #include <stdint.h>
/* States in a thread's life cycle. */ /* States in a thread's life cycle. */
enum thread_status enum thread_status {
{
THREAD_RUNNING, /* Running thread. */ THREAD_RUNNING, /* Running thread. */
THREAD_READY, /* Not running but ready to run. */ THREAD_READY, /* Not running but ready to run. */
THREAD_BLOCKED, /* Waiting for an event to trigger. */ THREAD_BLOCKED, /* Waiting for an event to trigger. */
......
...@@ -22,8 +22,8 @@ void populate_stack(void** stack_pointer, int argc, char** argv) { ...@@ -22,8 +22,8 @@ void populate_stack(void** stack_pointer, int argc, char** argv) {
while (--i >= 0) while (--i >= 0)
{ {
*stack_pointer = *stack_pointer - (strlen(argv[i]) + 1) * sizeof(char); *stack_pointer = *stack_pointer - (strlen(argv[i]) + 1) * sizeof(char);
// Assigns the current reference of the stack pointer to the array
arr[i] = (uint32_t *)*stack_pointer; // Assigns the current reference of the stack pointer to the array arr[i] = (uint32_t *)*stack_pointer;
memcpy(*stack_pointer, argv[i], strlen(argv[i]) + 1); memcpy(*stack_pointer, argv[i], strlen(argv[i]) + 1);
} }
...@@ -35,7 +35,7 @@ void populate_stack(void** stack_pointer, int argc, char** argv) { ...@@ -35,7 +35,7 @@ void populate_stack(void** stack_pointer, int argc, char** argv) {
while (--i >= 0) while (--i >= 0)
{ {
move_stack_pointer(stack_pointer, -4); //32bit Moves the stack pointer back 4 move_stack_pointer(stack_pointer, -4); //Moves the stack pointer back 4
(*(uint32_t **)(*stack_pointer)) = arr[i]; (*(uint32_t **)(*stack_pointer)) = arr[i];
} }
......
/* /*
* Closes file descriptor fd. Exiting or terminating a process implicitly closes all its open file * Closes file descriptor fd. Exiting or terminating a process implicitly closes
* descriptors, as if by calling this function for each one. * all its open file descriptors, as if by calling this function for each one.
* Authored by Alex Stratford * Authored by Alex Stratford
*/ */
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
#include "lib/kernel/list.h" // Dependency for list_remove #include "lib/kernel/list.h" // Dependency for list_remove
int syscall_close(struct intr_frame *f) { int syscall_close(struct intr_frame *f) {
int file_descriptor = *((int*)f->esp + 1); // pop off first int argument from interrupt frame // pop off first int argument from interrupt frame
int file_descriptor = *((int*)f->esp + 1);
// Described in system_calls.h, stores file descriptors mapped to files // Described in system_calls.h, stores file descriptors mapped to files
struct file_map *f_map = get_file(file_descriptor); struct file_map *f_map = get_file(file_descriptor);
if (f_map == NULL) // Checking if file is empty or non-existent if (f_map == NULL) // Checking if file is empty or non-existent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment