Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Frankencelery committed Oct 28, 2012
2 parents 9bc8544 + af5607f commit 8b2fc7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/userprog/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,16 @@ release_child (struct wait_status *cs)
int
process_wait (tid_t child_tid)
{
while(1){}
struct list_elem * e;
struct thread * t = NULL;
struct wait_status * t = NULL;
struct thread * cur = thread_current();
for (e = list_begin (&cur->children); e != list_end (&cur->children);e = list_next (e)){
struct thread * t2 = list_entry (e, struct thread, allelem);
struct wait_status * t2 = list_entry (e, struct wait_status, elem);
if (t2->tid == child_tid){t = t2; break;}
}
if (t == NULL){return -1;}
sema_down(&(t->wait_status->dead));
return -1;
sema_down(&(t->dead));
return t->exit_code;
}

/* Free the current process's resources. */
Expand Down
11 changes: 5 additions & 6 deletions src/userprog/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ sys_halt (void)
static int
sys_exit (int exit_code)
{
struct thread *t = thread_current();
t->wait_status->exit_code = exit_code;
//printf("%s: exit(%d)\n", t->name, exit_code);
thread_current ()->wait_status->exit_code = exit_code;
sema_up(&(thread_current ()->wait_status->dead));
thread_exit ();
NOT_REACHED ();
}
Expand All @@ -197,16 +196,16 @@ sys_exit (int exit_code)
static int
sys_exec (const char *ufile)
{
/* Add code */
thread_exit ();
char *kfile = copy_in_string(ufile);
return process_execute(kfile);
}

/* Wait system call. */
static int
sys_wait (tid_t child)
{
process_wait(child);
//thread_exit ();
return process_wait(child);
}

/* Create system call. */
Expand Down

0 comments on commit 8b2fc7d

Please sign in to comment.