diff options
Diffstat (limited to 'src/userprog')
| -rw-r--r-- | src/userprog/process.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/userprog/process.c b/src/userprog/process.c index 437d6c0..5897c84 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -25,6 +25,9 @@ struct start_process_args // parent -> child char *file_name; + + // child -> parent + bool success; }; static thread_func start_process NO_RETURN; @@ -55,11 +58,15 @@ process_execute (const char *file_name) If thread_create fails we free and return immediately since we know that the thread didn't start. Otherwise, the child thread can be scheduled freely so we explicitly - wait for the child to signal that it has read the args. Only then can - we free resources and return the tid. */ + wait for the child to signal that it has read from and written to + the args. Only then can we free resources and return the tid. */ tid = thread_create (file_name, PRI_DEFAULT, start_process, &args); if (tid != TID_ERROR) { sema_down (&args.sema); + + //TODO push to list of children + if (!args.success) + tid = -1; } palloc_free_page (args.file_name); return tid; @@ -82,15 +89,12 @@ start_process (void *args_) printf("reading\n"); success = load (args->file_name, &if_.eip, &if_.esp); + args->success = success; sema_up (&args->sema); /* If load failed, quit. */ - if (success) { - //TODO report success - } else { - //TODO report failure + if (!success) thread_exit (); - } /* Start the user process by simulating a return from an interrupt, implemented by intr_exit (in |
