Operating Systems 2018F: Assignment 2

From Soma-notes
Revision as of 17:32, 2 October 2018 by Soma (talk | contribs) (Created page with "'''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 ?? points in...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 ?? points in ?? 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. [2] 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. [2] If you change line 68 of 3000compare.c to be data[i] = 'A'; (from count++;), what will the program do? Explain briefly.
  5. [1] How can you modify 3000pc so the consumer stops consuming once it finds an empty queue?

Old Questions

  1. [2] What is one way simple way you can modify 3000pc so the consumer consumes as the producer produces, i.e., the producer and the consumer move essentially in lock step? Your modification should not involve sleeping by either the producer or the consumer. Why does your change work? (To do this precisely is hard; to do this approximately involves a change to one line. The approximate solution is sufficient.)
  2. [2] How does the behavior of 3000pc change if you delete lines 149 and 152 (the if statement in wakeup_consumer())? Why? (Explain what the program does after this change and why it may be problematic.)
  3. [2] What happens if you delete line 231 (the call to wakeup_producer()) in 3000pc? Why?
  4. [2] How does the behavior of the program change if you change QUEUESIZE to 8? What about 128?