Assignment 7, due Mar. 9

Part of the homework for CS:3620, Spring 2018
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

On all assignments, your name must be legible as it appears on your University ID card! Assignments are due at the start of class on the day indicated (usually Friday). Exceptions will be by advance arrangement unless there is what lawyers call "an act of God" (something outside your control). Homework must be turned in on paper, either in class or in the teaching assistant's mailbox. Never push late work under someone's door!

  1. Background: Look at the code for mush distributed on Mar. 2 as part of the assignment for MP4. Some change were made. This question asks you to describe these changes from the perspective of a user with no access to the source code. You have access to the code, and you can use this to find the changes, and you can experiment with running mush to verify the impact of the changes, but your answer must not refer to the code, only to how the program works from a user perspective.

    a) The behavior of getcommand() has changed. There is one change that a user can observe. (0.4 points)

    b) The behavior of launch() has changed. There are two changes that a user can observe. (0.6 points)

  2. Background: Consider a bizarrely small machine with the following address formats:
           _ _ _ _ _ _ _ _ _
          |_|_|_|_|_|_|_|_|_|  Virtual address
          |page |   word    |
       _ _ _ _ _ _ _ _ _ _ _
      |_|_|_|_|_|_|_|_|_|_|_|  Physical address
      |  frame  |   word    |
    

    At one instant in time, the page table in the memory management unit contains the following (all information is shown in binary):

    0 0 0: 1 0 1 0 0 0 0 0 1
    0 0 1: 1 0 0 0 0 0 0 1 0
    0 1 0: 1 1 0 0 0 1 0 0 1
    0 1 1: 0 0 0 0 0 0 1 0 1
    1 0 0: 0 0 0 0 1 1 0 0 0
    1 0 1: 0 0 0 0 0 0 1 0 1
    1 1 0: 0 0 0 0 0 1 0 0 1
    1 1 1: 0 0 0 0 1 0 0 0 0
           _ _ _ _ _ _ _ _ _
    index:|_|_|_|_|_|_|_|_|_|  Virtual address
          |r w x| |  frame  |
          rights
    

    For each of the following virtual addresses, give the corresponding physical address, and state whether it is a legal memory address, and if legal, what access is permitted. (Illegal addresses permit no access.)

    a)   0 1 0 1 0 1 0 1 0
    b)   1 0 1 0 1 0 1 0 1
    c)   0 0 1 1 0 0 1 1 0
    d)   1 1 0 0 1 1 0 0 1
    e)   0 0 0 1 1 1 0 0 0

  3. Background: Read the man page for the mmap() kernel call in Linux. Consider the following code:
    char * f = mmap(
            NULL,
    	sysconf( _SC_PAGESIZE )*16,
    	PROT_READ, MAP_SHARED,
            open( "~/myfile", O_RDONLY ),
    	0
    );
    

    a) Write a for loop that prints the entire contents of ~/myfile assuming that it has been opened using the above code. (0.6 points)

    b) How many page faults occur, at minimum, during the execution of the code you wrote for part a? (0.2 points)

    c) Under what circumstances would more page faults occur than you suggested in part b. (0.2 points)