summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-28 02:11:34 +0200
committermanuel <manuel@mausz.at>2012-03-28 02:11:34 +0200
commitcafe7c8221908bdf285f07e6750e9ab99de61638 (patch)
treeddfe73a1251e7468c6c18d0f95ecf712b4885b4e
parent45ec0ee0c36ac4cff65cb1d00b9ae2534cb70da9 (diff)
downloadprogos-cafe7c8221908bdf285f07e6750e9ab99de61638.tar.gz
progos-cafe7c8221908bdf285f07e6750e9ab99de61638.tar.bz2
progos-cafe7c8221908bdf285f07e6750e9ab99de61638.zip
more fillin of proj0.txt
-rw-r--r--proj0.txt29
1 files 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.
80>> `struct' member, global or static variable, `typedef', or 80>> `struct' member, global or static variable, `typedef', or
81>> enumeration. Identify the purpose of each in 25 words or less. 81>> enumeration. Identify the purpose of each in 25 words or less.
82 82
83struct start_aux_data:
84char *args ...renamed from filename to args as we strip off the executable name
85 early and only store the commandline arguments
86
83---- ALGORITHMS ---- 87---- ALGORITHMS ----
84 88
85>> A2: Briefly describe how you implemented argument parsing. How do 89>> A2: Briefly describe how you implemented argument parsing. How do
86>> you arrange for the elements of argv[] to be in the right order? 90>> you arrange for the elements of argv[] to be in the right order?
87>> How do you avoid overflowing the stack page? 91>> How do you avoid overflowing the stack page?
88 92
93First we strip off the executable name from the command string and pass it to
94thread_create(). Thus we name threads by their executable.
95After passing the arguments through start_process(), load() and setup_stack()
96we first copy the whole arguments byte array following the executable name onto
97the stack. Afterwards we align the current stack address and proceed with
98creating the argv[]-pointers by walking through the already copied arguments
99in reverse order. This way we can replace all space characters with 0-characters
100and at the same time detect the start of every argument which we push onto the
101stack. Additional we check for possible stack overflow. The walking order is
102already the correct order necessary for the argv[]-pointers on the stack.
103As a last step we push the address of the executable name, the address of the
104argv[] itself, the number of commandline arguments and a fake return addres
105onto the stack.
106
107Overflowing is avoided calculating the end of the stack and checking the
108current stack pointer after every push of an argv[]-pointer entry.
109
89---- RATIONALE ---- 110---- RATIONALE ----
90 111
91>> A3: Why does Pintos implement strtok_r() but not strtok()? 112>> 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.
96>> and arguments. In Unix-like systems, the shell does this 117>> and arguments. In Unix-like systems, the shell does this
97>> separation. Identify at least two advantages of the Unix approach. 118>> separation. Identify at least two advantages of the Unix approach.
98 119
99 120* Possible bugs in the code will either just break the shell or allow code
121 execution with user privileges. Otherwise this could lead to a kernel oops
122 or even worse code execution within the kernel.
123TODO
100 124
101 SURVEY QUESTIONS 125 SURVEY QUESTIONS
102 ================ 126 ================
@@ -122,5 +146,4 @@ the quarter.
122 146
123>> Any other comments? 147>> Any other comments?
124 148
125 149TODO
126