CMSC 412 Midterm #2 (Spring 1998)


  1. (20 points) Disks: consider a disk with one surface and 100 tracks recorded evenly spaced between 0.5" to 3.5" from the center of the platter.
    1. Assume that you have a disk that can store 20 sectors per 2 inches of magnetic media that passes under the disk head, that the disk drive can have a different number of sectors per track for each track, and fractional sectors per track. What is the maximum capacity of this disk in sectors?
    2. Inside track is 2 1/2in and we can store 20 sectors per 2 inches so there are 10 sectors.

      Outside track is 2 7/2in and we can store 20 sectors per 2 inches so there are 70 sectors.

      Total sectors is the sum from 1 to 100 of evenly space values from 10 to 70 sectors, so we compute the average value and multiple by 100 to get total sectors (10 + 70)/2 * 100 = 4,000 sectors

    3. Assume the disk can only record at a single density (i.e., the sectors per track will be the same for each track), and the maximum density is still 20 sectors per 2 inches, what is the capacity of the disk?

    We must record everything at the inside density of 10 sectors per track so there are 10 * 100 = 1,00 sectors.

  2. (20 points) Synchronization: Recall that binary semaphore can only have values of 0 and 1, and counting semaphores can have values from 0 to n. Using binary semaphores, show how you can implement counting semaphores. Please indicate the binary semaphores and variables used, and their initial values.

    Pc: P(mutex)

    If (sem > 0) { sem--; V(mutex); }

    else { wait++; V(mutex); P(turn) }

    Vc: P(mutex)

    If (sem == limit) V(mutex)

    Else if (!waiting) { sem++; V(mutex); }

    Else { waiting--; V(mutex); V(turn); }


    Semaphores: mutex, turn

    Variables: waiting, sem, limit


  4. (20 Points) Consider a reference string 1,2,3,4,2,5,7,2,3,2,1,7,8
    1. How many page faults would there be using FIFO replacement and 4 page frames?
    2. 10 faults

    3. How many faults with LRU and 4 page frames?
    4. 9 faults

    5. How many faults using an optimal algorithm and 4 page frames?

    7 faults

  5. (20 points) Security
    1. UNIX file protection is applied on a per file basis, but AFS uses per-directory file protection, explain why AFS used per-directory file protection even though it is based on UNIX.
    2. AFS uses ACLs, which take more space to store than the 9 bits UNIX uses.

    3. A user has write privilege to a UNIX directory "goodStuff", but not to the file "protected" in the "goodStuff" directory, explain how the user can still modify the file "protected".
    4. cp goodStuff temp

      rm -f goodStuff

      mv temp goodStuff

    5. In an attempt to save storage space, someone suggests that rather than storing the salt characters for the UNIX password in the password file that we use the first two characters of the users name as the salt. Explain how this would impact the security of accounts on a single machine and on multiple machines.

    Within a node, all users that have the same first two letters in their user name will have the same salt which will allow multiple accounts to be tested for a single try of a dictionary attack. Between nodes, if the same account name uses the same password, this fact will be apparent if the password file is readable.

  6. (20 points) File-systems
    1. A UNIX system has just been rebooted (i.e., the file buffer and name translation caches are empty). What is the minimum number of disk blocks that must be read to get to the millionth byte of the file "/a/big/file" assuming the file-system uses 4KB blocks, and 32-bit inode numbers?


      1. read root inode (#2)
      2. read root directory and find "a"
      3. read inode for "/a"
      4. read directory chunk and find "big"
      5. read inode for "/a/big"
      6. read directory chunk and find "file"
      7. read inode for "/a/big/file"
      8. read indirect block for the file (since 4KB blocks hold 1024 inodes, files up to 4MB are in direct or indirect block)
      9. read the data block


    1. Explain why a bit vector implementation of a free block list can provide increased reliability and performance compared with keeping a list of free blocks where the first few bytes of each free block provide the logical sector number of the next free block.

Performance: bit vectors provide fast access to find clusters of adjacent free blocks

Reliability: if an item in a linked list is lost, the rest of the list is lost. With a bit vectors only the items are lost. Also, its possible to have multiple copies of the bit vector since it is a more compact representation.

Web Accessibility