CMSC 412 Midterm #2 (Spring 1998)
(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.
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?
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
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.
(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
(20 Points) Consider a reference string 1,2,3,4,2,5,7,2,3,2,1,7,8
- How many page faults would there be using FIFO replacement and 4 page frames?
10 faults
How many faults with LRU and 4 page frames?
9 faults
How many faults using an optimal algorithm and 4 page frames?
7 faults
(20 points) Security
- 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.
AFS uses ACL’s, which take more space to store than the 9 bits UNIX uses.
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".
cp goodStuff temp
rm -f goodStuff
mv temp goodStuff
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 user’s 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.
(20 points) File-systems
- 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?
read root inode (#2)
read root directory and find "a"
read inode for "/a"
read directory chunk and find "big"
read inode for "/a/big"
read directory chunk and find "file"
read inode for "/a/big/file"
read indirect block for the file (since 4KB blocks hold 1024 inodes, files up to 4MB are in direct or indirect block)
read the data block
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, it’s possible to have multiple copies of the bit vector since it is a more compact representation.