Skip to content
Snippets Groups Projects
Verified Commit 76b31ddb authored by a2-stratford's avatar a2-stratford Committed by ja3-saxby
Browse files

Adding files from other branch

parent a922951f
No related branches found
No related tags found
2 merge requests!22Merge Feature/system calls,!12Alex/exit system call
/* halt.c
Simple program to test whether running a user program works.
Just invokes a system call that shuts down the OS. */
#include <syscall.h>
int
main (void)
{
exit (5);
/* not reached */
}
#include "system_calls.h" #include "system_calls.h"
#include "threads/thread.h" #include "threads/interrupt.h" // Dependency for intr_frame struct
#include "threads/thread.h" // Dependency for thread struct
void syscall_exit(struct intr_frame *status) { void syscall_exit(struct intr_frame *f) {
struct thread *current_thread; // creates thread struct from thread.h struct thread *current_thread; // creates thread struct from thread.h
current_thread = thread_current(); // Sets current thread current_thread = thread_current(); // Sets current thread
current_thread->status = status; // Returning status to kernel // pop off first int argument from interrupt frame
int exit_code = *((int*)f->esp + 1);
current_thread->exit_code = exit_code; // Returns exit code to kernel
thread_exit(); // Exiting current thread thread_exit(); // Exiting current thread
return -1; // Returning -1 for success f->eax = -1; // Returning -1 for success
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment