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

Merge branch 'Alex/exit-system-call' into Test/syscall-test-branch

parents de64b806 d2f4e62b
No related branches found
No related tags found
No related merge requests found
...@@ -10,3 +10,4 @@ examples/libc.a ...@@ -10,3 +10,4 @@ examples/libc.a
examples/my examples/my
# Visual Studio folder # Visual Studio folder
/.vs /.vs
/CppProperties.json
...@@ -3,14 +3,20 @@ SRCDIR = .. ...@@ -3,14 +3,20 @@ SRCDIR = ..
# Test programs to compile, and a list of sources for each. # Test programs to compile, and a list of sources for each.
# To add a new test, put its name on the PROGS list # To add a new test, put its name on the PROGS list
# and then add a name_SRC line that lists its source files. # and then add a name_SRC line that lists its source files.
<<<<<<< HEAD
PROGS = cat cmp cp echo halt hex-dump ls mcat mcp mkdir pwd rm shell \ PROGS = cat cmp cp echo halt hex-dump ls mcat mcp mkdir pwd rm shell \
bubsort insult lineup matmult recursor my touch bubsort insult lineup matmult recursor my touch
=======
PROGS = cat cmp cp echo exit halt hex-dump ls mcat mcp mkdir pwd rm shell \
bubsort insult lineup matmult recursor my
>>>>>>> Alex/exit-system-call
# Should work from project 2 onward. # Should work from project 2 onward.
cat_SRC = cat.c cat_SRC = cat.c
cmp_SRC = cmp.c cmp_SRC = cmp.c
cp_SRC = cp.c cp_SRC = cp.c
echo_SRC = echo.c echo_SRC = echo.c
exit_SRC = exit.c
halt_SRC = halt.c halt_SRC = halt.c
hex-dump_SRC = hex-dump.c hex-dump_SRC = hex-dump.c
insult_SRC = insult.c insult_SRC = insult.c
......
File added
/* 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 */
}
...@@ -72,7 +72,7 @@ syscall_handler (struct intr_frame *f UNUSED) ...@@ -72,7 +72,7 @@ syscall_handler (struct intr_frame *f UNUSED)
break; break;
default: default:
printf ("WARNING: Invalid Syscall (%d)\n", syscall_number); printf ("WARNING: Invalid Syscall (%d)\n", syscall_number);
thread_exit ();
} }
// TODO: remove this call to exit as we don't want all syscalls to make the thread exit // TODO: remove this call to exit as we don't want all syscalls to make the thread exit
thread_exit ();
} }
/*
* Terminates the current user program, returning status to the kernel. If the
* Process’s parent waits for it (see below), this is the status that will be
* Returned. Conventionally, a status of 0 indicates success and nonzero values
* Indicate errors.
*
* Authored by Alex Stratford
*/
#include "system_calls.h" #include "system_calls.h"
#include "threads/interrupt.h" #include "threads/interrupt.h" // Dependency for intr_frame struct
#include "threads/thread.h" // Dependency for thread struct
void syscall_exit(struct intr_frame *f) { void syscall_exit(struct intr_frame *f) {
(void*)0; struct thread *current_thread; // creates thread struct from thread.h
current_thread = thread_current(); // Sets current thread
// 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
f->eax = -1; // Returning -1 for success
} }
\ No newline at end of file
...@@ -12,7 +12,7 @@ void syscall_halt(struct intr_frame *f); ...@@ -12,7 +12,7 @@ void syscall_halt(struct intr_frame *f);
* returned. Conventionally, a status of 0 indicates success and nonzero * returned. Conventionally, a status of 0 indicates success and nonzero
* values indicate errors. * 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 * Runs the executable whose name is given in cmd_line, passing any given
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment