diff options
Diffstat (limited to 'proj0.txt')
| -rw-r--r-- | proj0.txt | 29 |
1 files changed, 26 insertions, 3 deletions
| @@ -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 | ||
| 83 | struct start_aux_data: | ||
| 84 | char *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 | ||
| 93 | First we strip off the executable name from the command string and pass it to | ||
| 94 | thread_create(). Thus we name threads by their executable. | ||
| 95 | After passing the arguments through start_process(), load() and setup_stack() | ||
| 96 | we first copy the whole arguments byte array following the executable name onto | ||
| 97 | the stack. Afterwards we align the current stack address and proceed with | ||
| 98 | creating the argv[]-pointers by walking through the already copied arguments | ||
| 99 | in reverse order. This way we can replace all space characters with 0-characters | ||
| 100 | and at the same time detect the start of every argument which we push onto the | ||
| 101 | stack. Additional we check for possible stack overflow. The walking order is | ||
| 102 | already the correct order necessary for the argv[]-pointers on the stack. | ||
| 103 | As a last step we push the address of the executable name, the address of the | ||
| 104 | argv[] itself, the number of commandline arguments and a fake return addres | ||
| 105 | onto the stack. | ||
| 106 | |||
| 107 | Overflowing is avoided calculating the end of the stack and checking the | ||
| 108 | current 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. | ||
| 123 | TODO | ||
| 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 | 149 | TODO | |
| 126 | |||
