diff --git a/Makefile.build b/Makefile.build index c079897805d7fb75ae1510b92d5e9af7dc59a224..5de0435e32aaf11c64669f2a6daff2b53cce1175 100644 --- a/Makefile.build +++ b/Makefile.build @@ -63,10 +63,11 @@ userprog_SRC += userprog/syscall.c # System call handler. userprog_SRC += userprog/gdt.c # GDT initialization. userprog_SRC += userprog/tss.c # TSS management. userprog_SRC += userprog/syscall_exec.c -userprog_SRC += userprog/syscall_open.c +userprog_SRC += userprog/syscall_exit.c userprog_SRC += userprog/syscall_halt.c userprog_SRC += userprog/syscall_wait.c userprog_SRC += userprog/syscall_create.c +userprog_SRC += userprog/syscall_open.c # No virtual memory code yet. #vm_SRC = vm/file.c # Some file. diff --git a/userprog/syscall.c b/userprog/syscall.c index a494704341d8785dfd0ec0c772c4d9e3dbb38167..1e5386ee77d467b6fbcc24c55755959e13b8f431 100644 --- a/userprog/syscall.c +++ b/userprog/syscall.c @@ -58,6 +58,9 @@ syscall_handler (struct intr_frame *f UNUSED) case SYSCALL_HALT: syscall_halt(f); break; + case SYSCALL_EXIT: + syscall_exit(f); + break; case SYSCALL_EXEC: syscall_exec(f); break; @@ -74,5 +77,4 @@ syscall_handler (struct intr_frame *f UNUSED) 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 } diff --git a/userprog/system_calls.h b/userprog/system_calls.h index b69bb44a4016b5408e4ce49197656085d47b6e28..e7027a9a3ed73a67f735beb06004289f92a2d8cd 100644 --- a/userprog/system_calls.h +++ b/userprog/system_calls.h @@ -18,6 +18,14 @@ struct file_map */ void syscall_halt(struct intr_frame *f); +/* + * 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. + */ +void syscall_exit(struct intr_frame *status); + /* * Runs the executable whose name is given in cmd_line, passing any given * arguments, and returns the new process's program id (pid). Must return pid @@ -34,19 +42,13 @@ void syscall_exec(struct intr_frame *f); void syscall_wait(struct intr_frame *f); /* -<<<<<<< HEAD * Creates a new file called file initially initial_size bytes in size. * Returns true if successful, false otherwise. */ void syscall_create(struct intr_frame *f); /* - * NOTE: There are more system calls implemented by Pintos but we are not - * implementing them because the assignment brief does not ask of it. - */ -======= * Opens the file called file. Returns a nonnegative integer handle called a * "file descriptor" (fd), or -1 if the file could not be opened. */ void syscall_open(struct intr_frame *f); ->>>>>>> Alex/27-implement-open-system-call