Difference between revisions of "Operating Systems 2019W: Assignment 1"

From Soma-notes
Jump to navigation Jump to search
Line 11: Line 11:
# [1] If line 293 from 3000shell.c is removed, <tt>pid = wait(ret_status);</tt>, how will the behavior of 3000shell change?
# [1] If line 293 from 3000shell.c is removed, <tt>pid = wait(ret_status);</tt>, how will the behavior of 3000shell change?
# [1] How would the behaviour of 3000shell change if lines 299 and 300 were removed?
# [1] How would the behaviour of 3000shell change if lines 299 and 300 were removed?
# [1] What does the call to setup_comm_fn() for in line 167 do?
# [1] What does the call to setup_comm_fn() in line 167 of 3000shell.c do?
# [2] Are system calls used to set signal handlers?  Use output from <tt>strace</tt> to show your answer is correct.
# [2] Are system calls used to set signal handlers?  Use output from <tt>strace</tt> to show your answer is correct.
# [2] Does find_env() generate any system calls?  Use output from <tt>strace</tt> to show your answer is correct.
# [2] Does find_env() generate any system calls?  Use output from <tt>strace</tt> to show your answer is correct.

Revision as of 23:03, 22 January 2019

Please submit the answers to the following questions via CULearn by 4 PM on January 28, 2019. There are 20 points in 11 questions.

Submit your answers as a single text file named "<username>-comp3000-assign1.txt" (where username is your MyCarletonOne username). The first four lines of this file should be "COMP 3000 Assignment 1", your name, student number, and the date of submission. You may wish to format your answers in Markdown to improve their appearance.

No other formats will be accepted. Submitting in another format will likely result in your assignment not being graded and you receiving no marks for this assignment. In particular do not submit an MS Word, OpenOffice, or PDF file as your answers document!

Don't forget to include what outside resources you used to complete each of your answers, including other students, man pages, and web resources. You do not need to list help from the instructor, TA, or information found in the textbook.

Questions

  1. [1] When you run a program from 3000shell, what does that program get for file descriptors 0, 1, and 2? Assume that you are running 3000shell in a standard terminal on Linux.
  2. [1] If line 293 from 3000shell.c is removed, pid = wait(ret_status);, how will the behavior of 3000shell change?
  3. [1] How would the behaviour of 3000shell change if lines 299 and 300 were removed?
  4. [1] What does the call to setup_comm_fn() in line 167 of 3000shell.c do?
  5. [2] Are system calls used to set signal handlers? Use output from strace to show your answer is correct.
  6. [2] Does find_env() generate any system calls? Use output from strace to show your answer is correct.
  7. [2] Give the assembly code corresponding to the allocation of pattern[] on line 63. Note that this allocation may be for multiple variables. How do you know your answer is correct?
  8. [2] How can execve overwrite all of a process's memory while also preserving its file descriptors? Specifically, does preserving file descriptors require execve to avoid erasing some process memory?
  9. [2] Is the SA_RESTART flag on a signal handler (e.g., line 243) interpreted by code running in the process or in the kernel? Give evidence for your answer.
  10. [3] Implement a "listfiles" command that lists the files in the current directory. Give the code for the listfiles() function and show how you'd change the rest of the code so that typing "listfiles" runs this function. Show your changes by using diff -c.
  11. [3] Implement an "input from file" feature to csimpleshell that works as follows. If you run
    $ bc infile=foo.bc
    then csimpleshell should have bc read the contents of foo.bc from standard input. You may assume that the "infile=" parameter is the last one (other than perhaps &). Show your changes from the standard csimpleshell.c using diff -c.