CMSC 412
Midterm #2 (Spring 2003)
1.)
(20 points) Define and
explain the following terms:
a)
Inverted Page Table
A
page table organized by physical page frames rather than by virtual address.
This reduces the size of the pages table to one entry per physical page
frame. It often uses a hash table to
provide virtual address to physical address translation.
b)
Virtual Address
An
address that is translated via a page table to a physical address. This allows
all processes to think their memory starts a virtual address 0.
c)
Rotational Latency
The
time required for a disk drive to wait until the head spins under the desired
sector (once the disk is at the required track).
d)
Thrashing
A
severe shortage of memory caused by not being able to fit the working sets of
all active processes into memory at once.
This results in high I/O (paging) rates and low CPU utilization.
2.)
(20 points) Memory
Systems: Consider a system with an average memory access time of 100
nano-seconds, a three level page table (meta-directory, directory, and page
table). For full credit, your answer must be a single number and not a formula.
a)
If the system had an average page fault rate of 0.01% for any
page accessed (data or page table related), and an average page fault took
1msec to service, what is the effective memory access time (assume no TLB or
memory cache).
EAT = 4 access to memory
(3 page related + memory) X time for one access
= 4 (100 ns + 1/10,000(1,000,000 ns) = 4 x 200ns = 800ns
b)
Now assume the system has no page faults, we are considering
adding a TLB that will take 1 nano-second to lookup an address translation.
What hit rate (to the nearest 5%) in the TLB is required to reduce the
effective access time to memory by a factor of 2.5?
Need access time of 2/5
* 400 = 160 ns
Access time = 100 X +
(1-x) 400 – 100 ns for hit (read memory), 400ns for miss
160 = 100 x + 400 – 400x
à x = .8 à 80% TLB hit rate
3.)
(20 Points) Synchronization: Given a multi-processor system
that supports a single global lock via: Lock(). Unlock(), and the ability to
suspend a process with a Wait(id) call, and the ability to wakeup all processes
waiting on an id, with Wakup(id). Show
how to implement counting semaphores.
typedef struct {
int count;
} Semaphore;
P(Semaphore *sem)
While
(1) {
Lock();
If (sem->count > 0)
Sem->count--;
Unlock();
Return;
Else
Unlock();
Wait();
}
V(Semaphore *sem)
Lock();
Sem->count++;
If (sem->count
== 1)
Wakeup(sem)
Unlock();
4.)
(15 points) File
Abstraction
a)
(10 points) Explain why the write and close system calls may
not result in data immediately being written to disk.
Files are often kept in a file buffer
cache even after a close to allow disks writes to be optimized (i.e. process
many requests in a single sweep across the drive).
b)
(5 points) Does the
seek system call result in a disk head moving (explain your answer)?
No, the seek system call simply moves
the pointer in the open file data structure, it is a read or write than can
result in the head being seeked.
5.)
(10 points) Explain
how you were able to use the accessed bit in the IA-32 (aka x86) processor to
simulate LRU page replacement in the project. How is this a more accurate
approximation than a simple second chance algorithm?
By dividing the pages into
epochs. Each page fault (or other clock
interval), we examine and clear the accessed bit. For those pages whose accessed bit was set, we change their clock
value to the current clock. Second
chance only has two epochs (accessed and not).
6.)
(15 points) Filesystems
a)
(5 points) List two issues that must be addressed to handle
DAG directories (vs. simple tree directories)
Backups needs to be carefully written
to not backup files with multiple names twice.
Need to maintain reference counts in
the inodes to know when the underlying file should be deleted.
b)
(5 points) What are
the 12 protection bits used in a UNIX filesystem?
Read, write, and execute for each of
user, group, and other/world
Setuid, set group id, sticky
c)
(5 points) How can an
access control list be used to represent negative rights to a file or
directory?
A field in each entry in the access list could
indicate that this is a negative right. As part of the checking of access
rights, after checking if an access is allowed, check the negative access to
see if the specific user should be disallowed.