From aa03d859f67cef7496d43e5e0c1c26aa0ee2044d Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Mon, 25 May 2020 14:00:30 +0200 Subject: [PATCH] hw5: mostly done --- pintos-env/pintos/threads/thread.c | 4 +++- pintos-env/pintos/userprog/syscall.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pintos-env/pintos/threads/thread.c b/pintos-env/pintos/threads/thread.c index 361a083..7305c7b 100644 --- a/pintos-env/pintos/threads/thread.c +++ b/pintos-env/pintos/threads/thread.c @@ -427,6 +427,7 @@ thread_exit (void) { ASSERT (!intr_context ()); + #ifdef USERPROG process_exit (); #endif @@ -436,7 +437,7 @@ thread_exit (void) when it calls thread_schedule_tail(). */ intr_disable (); struct thread* t = thread_current(); - //printf("Exit status: %d\n",t->exit_status); + printf("%s: exit(%d)\n", t->name, t->exit_status); list_remove (&t->allelem); sema_up(&t->waiting_sem); sema_down(&t->parent->parent_sem); @@ -589,6 +590,7 @@ init_thread (struct thread *t, const char *name, int priority) sema_init(&t->waiting_sem, 0); sema_init(&t->parent_sem, 0); t->waited_on_before = 0; + t->exit_status = -1; list_init(&t->children); if (thread_mlfqs) { diff --git a/pintos-env/pintos/userprog/syscall.c b/pintos-env/pintos/userprog/syscall.c index 9eabd30..665bf8b 100755 --- a/pintos-env/pintos/userprog/syscall.c +++ b/pintos-env/pintos/userprog/syscall.c @@ -218,7 +218,10 @@ int sys_read(int fd, void *buffer, unsigned size) { } int sys_write(int fd, const void *buffer, unsigned size) { - if (check_ptr(buffer)||check_ptr(buffer+size)) return -1; + unsigned i; + for (i = 0; i <= size; i++) { + if (check_ptr(buffer + size)) return -1; + } int ret; if(fd == 1) { // write to stdout @@ -266,7 +269,6 @@ int sys_exit (int status) { struct thread* t = thread_current(); - printf("%s: exit(%d)\n", t->name, status); t->exit_status = status; thread_exit(); return -1;