Cs241fa09hw2 Solutions
Cs241fa09hw2 Solutions
ANSWER KEY
1. Two schemes are commonly used to manage free spaces for memory dynamic partitions: bit map
and linked list. Which of the following is correct about these two schemes:
A. In most cases, linked list is more space efficient
B. In terms of processing time (updating the data structure due to allocation and
deallocation), linked list is faster on average.
C. On average, linked list is faster to find a free hole.
D. A and B
E. A and C (ANSWER)
F. All of the above
2. Which one of the following best describes the Translation Lookaside Buffer?
A. Is used to convert a physical address into a page offset.
B. Is used to convert a virtual address into a page offset.
C. Is used to cache the results of recent virtual page requests. (ANSWER)
D. Is used for asynchronous virtual memory updates in concurrent systems.
E. Is used to create process queues in a public virtual address space.
3. A server is 95% utilized. Assuming a single queue, Poisson arrivals, and exponentially distributed
service times, if the average service rate is 10 requests/second, what is the average queuing time
for an incoming request?
A. 0.1 seconds
B. 0.95 seconds
C. 1.8 seconds
D. 1.9 seconds (ANSWER) =9.5; =10; Wq = /( - )
E. 2.0 seconds
4. If the incoming request rate on the above server dropped until its average utilization became
90%, what is the average number of requests in the entire system?
A. 0.9 requests
B. 8.1 requests
C. 9.0 requests (ANSWER): L = /(1 - ) = 9
D. 10.0 requests
E. None of the above
5. Which of the following is the correct order of (a subset of) calls for a TCP client?
A. socket(); bind(); listen(); accept();
B. bind(); socket(); listen(); accept();
C. bind(); socket(); recvfrom();
D. socket(); bind(); recvfrom();
E. socket(); connect(); (ANSWER)
CS 241, Homework #2, Fall 2009 NetID: ______________________
6. Which one of the following best describes disk I/O using polling?
A. CPU time is required to continually check the status of I/O hardware and read/write bytes
as needed (ANSWER)
B. The CPU is interrupted when the I/O device is ready to transfer bytes
C. The I/O device transfers bytes to main memory without CPU intervention.
D. The I/O device uses a poll channel to halt the current CPU instruction.
E. The system bus is cross-linked to the memory bus during I/O transfer.
9. Consider a series of disk cylinder requests that arrive to the disk controller at exactly the same
time: 50, 81, 55, 20, 120, 65, 35. If the disk head is currently on cylinder 61, which request is
served last using Shortest Seek Time First?
A. 120 (ANSWER)
B. 81
C. 65
D. 20
10. Assuming a page size of 4096 bytes and that a page table entry takes 4 bytes, how many levels
of page table would be required to map a 42-bit address space (byte-addressable) if the top level
page table fits into a single page?
A. 1
B. 2
C. 3 (ANSWER)
D. 4
CS 241, Homework #2, Fall 2009 NetID: ______________________
11. Suppose your machine has 32 bit addresses and uses a 2-level page table. Virtual addresses are
split into: a 8 bit top-level page table field, an 12 bit second level page table field, and an offset.
A. (1 point) How large are the pages?
12. Consider the following page table below. All numbers are decimal, everything is numbered
starting from zero, and all addresses are memory byte addresses. The page size is 1024 bytes
and the processor architecture is 32-bit.
What physical address, if any, would each of the following virtual addresses correspond to? (Do
not try to handle any page faults if any). Note that the addresses are decimal addresses, not
hexadecimal addresses
A. (1 point) Virtual Memory Address: 1052 (decimal)
2221 -> 2221/1024 = 2 pages and 173 offset - this page is invalid and it is not in main
memory so it can’t be translated into physical memory address
5499 -> 5499/1024 = 5 pages and 379 offset – this page maps to 0 page frame , hence
CS 241, Homework #2, Fall 2009 NetID: ______________________
13. (1 point) In some machine architecture, the TLB access time is 1 clock cycle and the memory
access time is 10 clock cycles. What’s the minimum TLB hit ratio for TLB to be worthwhile? You
can assume that the page table needs a single memory access.
ANSWER: 0.1
(1 + 10) * α + (1 + 20) * (1 –α ) <= 20
α>= 0.1
14. Consider a system with 4 page frames. Given the virtual memory reference string 0, 1, 7, 2, 3, 2,
7, 1, 0, 3 how many page faults occur if FIFO page replacement algorithm is used? How about
LRU? Your answer should show the final content of the page frames after the 10 page references
and the number of page faults.
A. (1 point) First In First Out (FIFO) Page Replacement
15. An inode-based file system is mounted on a disk with 4Kbyte blocks. Block addresses (also
called “block pointers”) are 32 bits. A disk inode contains 10 direct entries, a single indirect, a
double indirect and a triple indirect entry. Single indirection is used once all ten direct entries are
filled. What is the largest file (in Kbytes) that can be stored in the following situations:
A. (1 point) When half of the direct entries are utilized?
ANSWER: 20 Kbytes
(10 total direct blocks) * (0.5 half full) * 4 KB block size = 5 * 4 KB = 20 KB
B. (1 point) When half of the entries in the single indirect block are utilized?
16. Consider the following program displayed below. There are six lines that have been marked to
be filled in with code that we provide (on the next page). It may not be necessary to fill each line.
If you complete all that is required of the code before filling all the provided lines for that chunk of
code, simply choose the last option (“/* No coded needed on this line. */”). DO NOT provide your
own code.
// Create a timer
timer_create(CLOCK_REALTIME, NULL, &timer);
while(1)
{
// Synchronously wait for the appropriate signal (the timer).
(4) ____________________________________
(5) ____________________________________
Please use one of these options to fill in each of the six lines marked in the code above. Please
note that is may be necessary to use one or more of the lines for multiple answers. If you have
completed all tasks necessary in the code and have lines remaining, please use the last answer
to denote that no more functions are required.
(6 x 1point) Provide your answer below (just supplying the letter corresponding with the answer
is enough):