Browse files

updates

  • Loading branch information...
2 parents 9bc8544 + af5607f commit 8b2fc7d5971c06ed21d1ef45df53b6360cbf5f0b @Frankencelery Frankencelery committed Oct 28, 2012
Showing with 9 additions and 11 deletions.
  1. +4 −5 src/userprog/process.c
  2. +5 −6 src/userprog/syscall.c
View
9 src/userprog/process.c
@@ -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. */
View
11 src/userprog/syscall.c
@@ -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 ();
}
@@ -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. */

0 comments on commit 8b2fc7d

Please sign in to comment.