From 99c3962a424b30ddeaa273a75e737a37bed72edb Mon Sep 17 00:00:00 2001 From: Alex Stratford <alexander3.stratford@live.uwe.ac.uk> Date: Mon, 2 Dec 2019 21:20:14 +0000 Subject: [PATCH] Implemented the exit system call --- .gitignore | 1 + userprog/syscall_exit.c | 11 ++++++++--- userprog/system_calls.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index b3ddb41..fe04185 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ examples/libc.a examples/my # Visual Studio folder /.vs +/CppProperties.json diff --git a/userprog/syscall_exit.c b/userprog/syscall_exit.c index 07d917f..4441a27 100644 --- a/userprog/syscall_exit.c +++ b/userprog/syscall_exit.c @@ -1,6 +1,11 @@ #include "system_calls.h" -#include "threads/interrupt.h" +#include "threads/thread.h" -void syscall_exit(struct intr_frame *f) { - (void*)0; +void syscall_exit(struct intr_frame *status) { + struct thread *current_thread; // creates thread struct from thread.h + current_thread = thread_current(); // Sets current thread + + current_thread->status = status; // Returning status to kernel + thread_exit(); // Exiting current thread + return -1; // Returning -1 for success } diff --git a/userprog/system_calls.h b/userprog/system_calls.h index 5d07273..7d31857 100644 --- a/userprog/system_calls.h +++ b/userprog/system_calls.h @@ -12,7 +12,7 @@ void syscall_halt(struct intr_frame *f); * returned. Conventionally, a status of 0 indicates success and nonzero * values indicate errors. */ -void syscall_exit(struct intr_frame *f); +void syscall_exit(struct intr_frame *status); /* * Runs the executable whose name is given in cmd_line, passing any given -- GitLab