Operating Systems 2018F: Assignment 2

From Soma-notes
Revision as of 16:49, 3 October 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 Wednesday, October 10, 2018. There are 10 points in 9 questions.

Submit your answers as a single text file named "<username>-comp3000-assign2.txt" (where username is your MyCarletonOne username). The first four lines of this file should be "COMP 3000 Assignment 2", 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] Assume you have a file A. You type ln A B in order to create file B. What is the relationship between the return of lstat() on A versus B? Explain briefly.
  2. [1] Assume you have a file A. You type ln -s A B in order to create file B. What is the relationship between the return of lstat() on A versus B? Explain briefly.
  3. [1] How could you modify 3000test.c so it can report on what a file's user ID and group ID are and the corresponding username and group name? Specify the changes you make rather than writing all the code out. (In other words, code a solution and explain the changes you made here.)
  4. [1] If you change line 68 of 3000test.c to be data[i] = 'A'; (from count++;), what will the program do? Explain briefly.
  5. [1] What does setup_comm_fn() do in 3000shell?
  6. [1] How can you modify 3000pc so the consumer stops consuming once it finds an empty queue?
  7. [1] What would happen to 3000pc if we replaced lines 341-347 with s = (shared *) malloc(sizeof(shared));? Why?
  8. [1] In 3000pc, what happens if you remove the calls to kill()? What does this tell you about the roles of signals in this program?
  9. [1] Is it possible to predict the output of /dev/random? Explain briefly.
  10. [1] Do sem_wait() and sem_post() generate system calls? (Be sure to check!) Why?