Operating Systems 2019W: Assignment 1

From Soma-notes
Revision as of 18:09, 20 January 2019 by Soma (talk | contribs) (Created page with "'''This assignment is not yet finalized, please do not answer these questions yet!''' Please submit the answers to the following questions via CULearn by 2:30 PM on September...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This assignment is not yet finalized, please do not answer these questions yet!

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] 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. [2] Are system calls used to set signal handlers? Use output from strace that shows your answer is correct.
  4. [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?
  5. [1] How could you change 3000shell so that it generates zombie processes?
  6. [2] How would the behaviour of 3000shell change if line 286 was removed? (pid = fork();) Why?
  7. [2] In 3000shell, when are lines 299 and 300 executed? Why?
  8. [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?
  9. [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.
  10. [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 (from your experience with 3000shell)?
  11. [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?
  12. [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.
  13. [2] Describe how you could add output redirection for external programs to 3000shell.