diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-02-19 12:14:36 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-02-19 12:15:29 +0100 |
| commit | 495d3cf2bdf5e1ce0654f37a3d983d55e098964d (patch) | |
| tree | d150e97c258e079eccd3fef4b5a92f622974550d /src | |
| parent | 3ed3ba31adb9c84bcca000a5f31c5278211bd3ae (diff) | |
| download | pintos-495d3cf2bdf5e1ce0654f37a3d983d55e098964d.tar.gz | |
prepare for lab 3
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/pid_t.h | 15 | ||||
| -rw-r--r-- | src/lib/user/syscall.h | 4 | ||||
| -rw-r--r-- | src/userprog/syscall.c | 13 |
3 files changed, 28 insertions, 4 deletions
diff --git a/src/lib/pid_t.h b/src/lib/pid_t.h new file mode 100644 index 0000000..c6d8e31 --- /dev/null +++ b/src/lib/pid_t.h @@ -0,0 +1,15 @@ +#ifndef LIB_PID_T_H +#define LIB_PID_T_H + +/* Process identifier. + Moved from lib/user/syscall.h since both kernel- + and user-space want the same definition. */ +typedef int pid_t; + +#define PID_ERROR ((pid_t) -1) + +/* Format specifier for printf(), e.g.: + printf ("pid=%"PRPTd"\n", pid); */ +#define PRPTd d + +#endif /* lib/pid_t.h */ diff --git a/src/lib/user/syscall.h b/src/lib/user/syscall.h index 8a9e0c0..a152dd1 100644 --- a/src/lib/user/syscall.h +++ b/src/lib/user/syscall.h @@ -4,9 +4,7 @@ #include <stdbool.h> #include <debug.h> -/* Process identifier. */ -typedef int pid_t; -#define PID_ERROR ((pid_t) -1) +#include "lib/pid_t.h" /* Map region identifier. */ typedef int mapid_t; diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 4ff0340..65ebc7e 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -8,6 +8,7 @@ #include "filesys/file.h" #include "filesys/filesys.h" #include "filesys/off_t.h" +#include "lib/pid_t.h" #include "threads/init.h" #include "threads/malloc.h" @@ -67,7 +68,7 @@ get_fd (struct thread *thread, int fd_i) } static void -exit (int status) +exit (int status UNUSED) { struct thread *thread = thread_current (); @@ -142,6 +143,12 @@ close (int fd_i) } } +static pid_t +exec (const char *file_name UNUSED) +{ + return -1; +} + // cast to TYPE and deref argument N from f->esp #define INTR_ESP(N, TYPE) *(TYPE *)(f->esp+(4*(N))) @@ -158,6 +165,10 @@ syscall_handler (struct intr_frame *f UNUSED) // exit exit (INTR_ESP (1, int)); break; + case 2: + // exec + f->eax = exec (INTR_ESP (1, char *)); + break; case 4: // create f->eax = create (INTR_ESP (1, char *), INTR_ESP (2, off_t)); |
