hw5: mostly done

This commit is contained in:
Claudio Maggioni 2020-05-25 14:00:30 +02:00
parent 71591aa85c
commit aa03d859f6
2 changed files with 7 additions and 3 deletions

View File

@ -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) {

View File

@ -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;