diff --git a/examples/bubsort.o b/examples/bubsort.o new file mode 100644 index 0000000000000000000000000000000000000000..9524f9a47cba9d11f19ea3f275d554f937a1b0c0 Binary files /dev/null and b/examples/bubsort.o differ diff --git a/examples/cat.o b/examples/cat.o new file mode 100644 index 0000000000000000000000000000000000000000..792e969dd327b7015df12d79f169f56285c01b0d Binary files /dev/null and b/examples/cat.o differ diff --git a/examples/cmp.o b/examples/cmp.o new file mode 100644 index 0000000000000000000000000000000000000000..c43a9bc6abe37246f055fd56ec07ec56019545ec Binary files /dev/null and b/examples/cmp.o differ diff --git a/examples/cp.o b/examples/cp.o new file mode 100644 index 0000000000000000000000000000000000000000..f504b543cdbf80f841121edf4c03611bb62e00b4 Binary files /dev/null and b/examples/cp.o differ diff --git a/examples/echo.o b/examples/echo.o new file mode 100644 index 0000000000000000000000000000000000000000..02dcf47ca43df2732b8393c1d536349f5ce1c8c8 Binary files /dev/null and b/examples/echo.o differ diff --git a/examples/halt.o b/examples/halt.o new file mode 100644 index 0000000000000000000000000000000000000000..0d0b220042846cffafbed3e2b9b75b9fa0858751 Binary files /dev/null and b/examples/halt.o differ diff --git a/examples/hex-dump.o b/examples/hex-dump.o new file mode 100644 index 0000000000000000000000000000000000000000..84bf2e0ba38f843b36afeddc1afbbca8204c9f42 Binary files /dev/null and b/examples/hex-dump.o differ diff --git a/examples/insult.o b/examples/insult.o new file mode 100644 index 0000000000000000000000000000000000000000..b350ac6f0ad017c301a87c40407ca9164d6b611f Binary files /dev/null and b/examples/insult.o differ diff --git a/examples/lib/arithmetic.o b/examples/lib/arithmetic.o new file mode 100644 index 0000000000000000000000000000000000000000..40343b938f55cfce3992bcd53497e0668d86a311 Binary files /dev/null and b/examples/lib/arithmetic.o differ diff --git a/examples/lib/debug.o b/examples/lib/debug.o new file mode 100644 index 0000000000000000000000000000000000000000..060705a95d2395d477c32ad608006840b8e76932 Binary files /dev/null and b/examples/lib/debug.o differ diff --git a/examples/lib/random.o b/examples/lib/random.o new file mode 100644 index 0000000000000000000000000000000000000000..751fb61787df349057158b5f837b6851284e8545 Binary files /dev/null and b/examples/lib/random.o differ diff --git a/examples/lib/stdio.o b/examples/lib/stdio.o new file mode 100644 index 0000000000000000000000000000000000000000..a4eebcd2e1690063cd87ebf3cfa43866b7a8985f Binary files /dev/null and b/examples/lib/stdio.o differ diff --git a/examples/lib/stdlib.o b/examples/lib/stdlib.o new file mode 100644 index 0000000000000000000000000000000000000000..b430f4b4fe34f4b55dabbbcc18104c439ca6576f Binary files /dev/null and b/examples/lib/stdlib.o differ diff --git a/examples/lib/string.o b/examples/lib/string.o new file mode 100644 index 0000000000000000000000000000000000000000..c5b0da48bbb97071e49faf0d1f93e726683ddcfc Binary files /dev/null and b/examples/lib/string.o differ diff --git a/examples/lib/user/console.o b/examples/lib/user/console.o new file mode 100644 index 0000000000000000000000000000000000000000..e6e37fb2028bf89d840b958ad1d952b2e162f7ce Binary files /dev/null and b/examples/lib/user/console.o differ diff --git a/examples/lib/user/debug.o b/examples/lib/user/debug.o new file mode 100644 index 0000000000000000000000000000000000000000..a9a07311b17637a6766d7423ece3e0e887a989a3 Binary files /dev/null and b/examples/lib/user/debug.o differ diff --git a/examples/lib/user/entry.o b/examples/lib/user/entry.o new file mode 100644 index 0000000000000000000000000000000000000000..5e90905078f6c9fd866efb6787196f5c04ce18a4 Binary files /dev/null and b/examples/lib/user/entry.o differ diff --git a/examples/lib/user/syscall.o b/examples/lib/user/syscall.o new file mode 100644 index 0000000000000000000000000000000000000000..b32c2b450b4a4a5cc4335da662ab90e5df9d4a7a Binary files /dev/null and b/examples/lib/user/syscall.o differ diff --git a/examples/lib/ustar.o b/examples/lib/ustar.o new file mode 100644 index 0000000000000000000000000000000000000000..de2cd4afe6d26e600f44519e8f1e588ded58310c Binary files /dev/null and b/examples/lib/ustar.o differ diff --git a/examples/libc.a b/examples/libc.a new file mode 100644 index 0000000000000000000000000000000000000000..35252a27d2598b076aa51fd0a707d232c338bfb4 Binary files /dev/null and b/examples/libc.a differ diff --git a/examples/lineup.o b/examples/lineup.o new file mode 100644 index 0000000000000000000000000000000000000000..e7746c678812deabf5bd26c51ab9a792218f4a16 Binary files /dev/null and b/examples/lineup.o differ diff --git a/examples/ls.o b/examples/ls.o new file mode 100644 index 0000000000000000000000000000000000000000..9fb3fde2d78453596155293b53f804a7e87f4638 Binary files /dev/null and b/examples/ls.o differ diff --git a/examples/matmult.o b/examples/matmult.o new file mode 100644 index 0000000000000000000000000000000000000000..615de3640f16cb83f9a0208ab771fb3ed0e3d228 Binary files /dev/null and b/examples/matmult.o differ diff --git a/examples/mcat.o b/examples/mcat.o new file mode 100644 index 0000000000000000000000000000000000000000..d4d8914ea8b3246d907f984f6be392060a7f8697 Binary files /dev/null and b/examples/mcat.o differ diff --git a/examples/mcp.o b/examples/mcp.o new file mode 100644 index 0000000000000000000000000000000000000000..1309078348f56513d93d250ab80004aa6dea953f Binary files /dev/null and b/examples/mcp.o differ diff --git a/examples/mkdir.o b/examples/mkdir.o new file mode 100644 index 0000000000000000000000000000000000000000..8d9daa94408f3b0593c7833d2f1562ae8dc02ff6 Binary files /dev/null and b/examples/mkdir.o differ diff --git a/examples/my b/examples/my new file mode 100755 index 0000000000000000000000000000000000000000..8307818f4e0b77ea694c14f45cbc7c61ad56729c Binary files /dev/null and b/examples/my differ diff --git a/examples/my.o b/examples/my.o new file mode 100644 index 0000000000000000000000000000000000000000..3b01878648d2245c58fe51437417e0ffc1b1a67f Binary files /dev/null and b/examples/my.o differ diff --git a/examples/pwd.o b/examples/pwd.o new file mode 100644 index 0000000000000000000000000000000000000000..4d9d638758afc4f4a00e356c6c11d77a359a7c17 Binary files /dev/null and b/examples/pwd.o differ diff --git a/examples/recursor.o b/examples/recursor.o new file mode 100644 index 0000000000000000000000000000000000000000..79ba498f8dd6e723069c31c02033e833b94b8d7b Binary files /dev/null and b/examples/recursor.o differ diff --git a/examples/rm.o b/examples/rm.o new file mode 100644 index 0000000000000000000000000000000000000000..d97cd85163a76df6fcb16122991b34a486aeb9dd Binary files /dev/null and b/examples/rm.o differ diff --git a/examples/shell.o b/examples/shell.o new file mode 100644 index 0000000000000000000000000000000000000000..13c2450a592f3648e72bcdf861e1740f595173ac Binary files /dev/null and b/examples/shell.o differ diff --git a/threads/thread.c b/threads/thread.c index 052302f8d417bbcce955ae4216fc297d956316a6..d8980f9b8e401f9bb9ee0b3dbf9251e5c541d75b 100644 --- a/threads/thread.c +++ b/threads/thread.c @@ -257,6 +257,13 @@ thread_name (void) return thread_current ()->name; } +/* Returns the exit code of the running thread. */ +const int * +thread_exit_code (void) +{ + return thread_current ()->exit_code; +} + /* Returns the running thread. This is running_thread() plus a couple of sanity checks. See the big comment at the top of thread.h for details. */ @@ -454,7 +461,8 @@ is_thread (struct thread *t) return t != NULL && t->magic == THREAD_MAGIC; } -/* Does basic initialization of T as a blocked thread named +/* Does basic initialization of T as a blocked thread +d NAME. */ static void init_thread (struct thread *t, const char *name, int priority) diff --git a/threads/thread.h b/threads/thread.h index 093bcddeb82e3c52182ff182c8c832d90f695908..b57608eee203024a22f821a64531938ca140300a 100644 --- a/threads/thread.h +++ b/threads/thread.h @@ -89,6 +89,7 @@ struct thread uint8_t *stack; /* Saved stack pointer. */ int priority; /* Priority. */ struct list_elem allelem; /* List element for all threads list. */ + int exit_code; /* Exit Code */ /* Shared between thread.c and synch.c. */ struct list_elem elem; /* List element. */ @@ -122,6 +123,7 @@ void thread_unblock (struct thread *); struct thread *thread_current (void); tid_t thread_tid (void); const char *thread_name (void); +const int *thread_exit_code (void); void thread_exit (void) NO_RETURN; void thread_yield (void); diff --git a/userprog/process.c b/userprog/process.c index d51339a4aff8ec7aae340ae87035ef64358853fd..0065486ead2325a70dd181a5ec4696cd079dbf10 100644 --- a/userprog/process.c +++ b/userprog/process.c @@ -37,7 +37,9 @@ process_execute (const char *file_name) if (fn_copy == NULL) return TID_ERROR; strlcpy (fn_copy, file_name, PGSIZE); + //Start of my shit + //End of my shit /* Create a new thread to execute FILE_NAME. */ tid = thread_create (file_name, PRI_DEFAULT, start_process, fn_copy); @@ -102,8 +104,13 @@ process_exit (void) { struct thread *cur = thread_current (); uint32_t *pd; + - /* Destroy the current process's page directory and switch back + // Add Process Termination Message + printf("%s: exit(%d)\n", thread_name(), thread_exit_code()); + //printf("%s: exit(%d)\n", cur->name, cur->exit_code); /*Alternate implementation using the struct cur*/ + +/* Destroy the current process's page directory and switch back to the kernel-only page directory. */ pd = cur->pagedir; if (pd != NULL) @@ -443,7 +450,7 @@ setup_stack (void **esp) { success = install_page (((uint8_t *) PHYS_BASE) - PGSIZE, kpage, true); if (success) { - *esp = PHYS_BASE; + *esp = PHYS_BASE - 12; } else palloc_free_page (kpage); }