From cafe7c8221908bdf285f07e6750e9ab99de61638 Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 28 Mar 2012 02:11:34 +0200 Subject: more fillin of proj0.txt --- proj0.txt | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/proj0.txt b/proj0.txt index 5052dfa..c4aa3dc 100644 --- a/proj0.txt +++ b/proj0.txt @@ -80,12 +80,33 @@ and fulfills the needs of project0. >> `struct' member, global or static variable, `typedef', or >> enumeration. Identify the purpose of each in 25 words or less. +struct start_aux_data: +char *args ...renamed from filename to args as we strip off the executable name + early and only store the commandline arguments + ---- ALGORITHMS ---- >> A2: Briefly describe how you implemented argument parsing. How do >> you arrange for the elements of argv[] to be in the right order? >> How do you avoid overflowing the stack page? +First we strip off the executable name from the command string and pass it to +thread_create(). Thus we name threads by their executable. +After passing the arguments through start_process(), load() and setup_stack() +we first copy the whole arguments byte array following the executable name onto +the stack. Afterwards we align the current stack address and proceed with +creating the argv[]-pointers by walking through the already copied arguments +in reverse order. This way we can replace all space characters with 0-characters +and at the same time detect the start of every argument which we push onto the +stack. Additional we check for possible stack overflow. The walking order is +already the correct order necessary for the argv[]-pointers on the stack. +As a last step we push the address of the executable name, the address of the +argv[] itself, the number of commandline arguments and a fake return addres +onto the stack. + +Overflowing is avoided calculating the end of the stack and checking the +current stack pointer after every push of an argv[]-pointer entry. + ---- RATIONALE ---- >> A3: Why does Pintos implement strtok_r() but not strtok()? @@ -96,7 +117,10 @@ strtok() uses global data, so it is unsafe in threaded programs such as kernels. >> and arguments. In Unix-like systems, the shell does this >> separation. Identify at least two advantages of the Unix approach. - +* Possible bugs in the code will either just break the shell or allow code + execution with user privileges. Otherwise this could lead to a kernel oops + or even worse code execution within the kernel. +TODO SURVEY QUESTIONS ================ @@ -122,5 +146,4 @@ the quarter. >> Any other comments? - - +TODO -- cgit v1.2.3