diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-02-21 19:34:35 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-02-21 19:44:26 +0100 |
| commit | ec5c4ad0b9cb68c0405728c913c42a3f5f412b37 (patch) | |
| tree | 7a4e8ff8379e3fa1d8441a8e540deb32d87e3edb /src/userprog | |
| parent | bd53394e2e05bf7897574f55ab6f88f7bcc2e258 (diff) | |
| download | pintos-ec5c4ad0b9cb68c0405728c913c42a3f5f412b37.tar.gz | |
child reports success of load to parent
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 |
