Operating Systems 2018F: Assignment 1

From Soma-notes
Revision as of 17:21, 19 September 2018 by Soma (talk | contribs) (→‎Questions)

This assignment is not yet finalized.

Please submit the answers to the following questions via CULearn by 2:30 PM on September 26, 2018. There are 20 points in 12 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 or OpenOffice 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] What does it mean to run a program "in the background"? Specifically, what is the key difference between running a program in the foreground and in the background?
  2. [1] Are system calls used to receive signals? Explain briefly. (Hint: strace a program and send it a signal. What happens?)
  3. [1] The system calls 3000shell uses to search for a program to run (in one of the PATH directories) are not the same as those used by standard shells such as bash. What's the difference?
  4. [1] How could you change 3000shell so that it generates zombie processes?
  5. [2] How would the behaviour of 3000shell change if line 286 was removed? (pid = fork();) Why?
  6. [2] In 3000shell, when are lines 299 and 300 executed? Why?
  7. [2] Does using getenv() generate any additional library calls (as reported by ltrace)? Does it generate any additional system calls (as reported by strace)? Why?
  8. [2] Does parse_args() allocate any memory on the heap (i.e., any memory that stays allocated after the function returns)? How do you know? Give a brief argument.
  9. [2] execve overwrites all of a process's memory with that of a new executable. Does execve also close all open file descriptors? How do you know?
  10. [2] What happens to an in-progress system call when a process receives a signal? (An example is a program waiting for input from a terminal with a blocking read call.) What does "restarting" a system call have to do with this?
  11. [2] If you changed plist() so it took proc_prefix as an argument (rather than accessing it as a global variable), what output would it produce when given an argument other than "/proc"? Explain briefly.
  12. [2] Describe how you could add output redirection for external programs to 3000shell.