Operating Systems 2019F: Assignment 2

From Soma-notes
Revision as of 22:03, 1 October 2019 by Soma (talk | contribs)

This assignment is not yet finalized.

Please submit the answers to the following questions via CULearn by 4 PM on Friday, October 11, 2019. There are 20 points in 10 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.

When asked to modify source files, you may want to give your code in "diff -c" format.

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 "animal.c". You type ln animal.c frog.c in order to create file "frog.c". If you rename "animal.c" to "animal-base.c", what happens when you try to edit "frog.c"? Why?
  2. [1] Assume you have a file "animal.c". You type ln -s animal.c penguin.c in order to create file "penguin.c". If you rename "animal.c" to "animal-base.c", what happens when you try to edit "penguin.c"? Why?
  3. [2] What dynamic symbols are defined in the object file for 3000shell.c (when compiled normally)? Where can you find the code or data referred to by these symbols?
  4. [2] Modify 3000test.c so it reports what the three times associated with an inode, atime, mtime, and ctime. What do these times mean and when are they updated on files on your system?
  5. [2] What x86-64 assembly instructions are used to put parameters on the call stack? How do you know? Show relevant assembly code and corresponding C code.
  6. [2] What x86-64 assembly instructions are used to allocate local variables? How do you know? Show relevant assembly code and corresponding C code.
  7. [2] Make a program redact-mmap.c that takes two arguments: a string s and a filename f. redact should mmap f into its address space and then replace every occurance of s with X's (with the number of X's corresponding to the length of s).
  8. [2] Make a program redact-rw.c that does the same thing as redact-mmap.c except that it uses reads and writes (of 4096 bytes at a time) rather than mmap.
  9. [3] Compare the performance of redact-mmap versus redact-rw. Which is faster on large files? Why do you think this is the case? Try using the time command to benchmark your programs, making sure to do at least ten trials.
  10. [3] What happens when process A mmap's file f and process B appends to file f. Will process A see the additional data added to the file by B (if A does no other system calls)? Design an experiment and document your results.