Push the value of argc then finally push a fake return point may be NULL. Then push the address of the stack position which contains the address of the string "echo\0", starred in the previous line. There-after push the addresses the strings on the stack just passed again in the same order. Then push a NULL pointer sentinal of type "uint32_t" corresponding to argv In order to make the esp pointer a multiple of 4 You need to remember the addresses on the stack where these strings are being pushed as u later to need to push these addresses as well. Push all the arguments onto the stack in reverse order. Insert your code after the page is successfully installed i.e inside Then your work is to set up the stack which is done in the function setup_stack called in the line 305. So that the correct program file will be opened since passing will cause an error as there won't be any such program file. The only thing is that instead of this argument, a pointer pointing to this string should be passed. You may want to look at the functions present in "lib/string.c" on how this can be done or create your own function to do this. Inside load is where you need to do the modifications.įirstly since the argument file_name_which is passed points to the string, You need to get the name of the user program which needs to loaded which in this case is 'echo'. Start_process creates the interrupt frame and goes on to load the user program and then run it. Process_execute() creates a new thread passing 'start_process' as the function to be performed whose task is to load this user program and the string is passed as well. Run task calls 'process_execute' located in 'userprog/process.c' with the pointer to this string. This leads to the calling of the function "run_task" (due to the argument run) with the argument argv which now points to the string. "run", which is nothing but a command which says run the program 'echo' with the arguments 'x' and 'y'. Run_actions determines what task needs to be done by using the first string available here i.e. " run echo x y " which is passed as a pointer named "argv" Main then calls run_actions with the following argument In the parse_options function appropriate flags are set indicating that the option has been acknowledged and that the PINTOS will be turned off once the task is completed.Īll the arguments which are pintos options will get parsed in this function. "-q"> this is just a pintos option for powering off the system once the processing is done. This causes the parsing of the arguments like this Running a typical User program involves issuing the following command This is done in the file "threads/init.c" in the 'main' function. Just like in a regular command line argument passing, Pintos already does the parsing of the arguments passed to it via command line. Stack pointer should point this return address.A brief intro to argument passing in Pintos When pushing arguments is done, load() should push return address where callee process returns. This should not violate calling convention, so they must push arguments right to left. Adjust start_process() and load() to make them match function parameters with given arguments.Implement a function that could handle parsing input into file name and its arguments, and apply it in process_execute().Create a struct for storing/indexing multiple arguments, and passing arguments in one pack.strtok_r() is given in the pintos document, which is thread-safe and could save leftovers of parsing in given pointer, which would be arguments of a file. This could be done by importing some of string-related functions in string.h. That is, process_execute("A b c d e") should execute file named A with b, c, d, and e as its arguments. Since even basic operators such as + needs two or more arguments to carry out tasks, this completely limits the range of tasks pintos could handle, and forces every callee functions to independently get data without help of caller functions.Ĭhange prototype of process_execute(), to make it support passing of data given as its argument. That is, it just simply executes a file with a given name, giving nothing to file that is being executed. Implement argument passing to support passing arguments to threads.Ĭurrent process_execute() does not support arguments.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |