Docsity

5 Problems on Systems Programming - Final Exam | CS 351, Exams of Computer Science

Toggle sidebar
bg1
Full Name:
CS 351 Fall 2009
Final Exam
December 9, 2009
Instructions:
โ€ขThis exam is closed-book, closed-notes. Calculators are not permitted.
โ€ขMake sure your full name is on the front, and that your exam is not missing any sheets.
โ€ขWrite your answers in the space provided for each problem. If you make a mess, clearly
indicate your final answer.
โ€ขThe problems are of varying difficulty. The point value of each problem is indicated. Pile up
the easy points quickly and then come back to the harder problems.
โ€ขGood luck!
1 (/10) :
2 (/12) :
3 (/12) :
4 (/12) :
5 (/12) :
TOTAL (/58) :
Page 1 of 9
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download 5 Problems on Systems Programming - Final Exam | CS 351 and more Exams Computer Science in PDF only on Docsity!

Full Name:

CS 351 Fall 2009

Final Exam

December 9, 2009

Instructions:

  • This exam is closed-book, closed-notes. Calculators are not permitted.
  • Make sure your full name is on the front, and that your exam is not missing any sheets.
  • Write your answers in the space provided for each problem. If you make a mess, clearly indicate your final answer.
  • The problems are of varying difficulty. The point value of each problem is indicated. Pile up the easy points quickly and then come back to the harder problems.
  • Good luck!

TOTAL (/58) :

Problem 1. (10 points):

Multiple choice. For each question, circle the letter corresponding to the single best answer.

  1. What policy decision may result in artificial external fragmentation?

(a) Quadruple word block alignment (b) Deferred coalescing (c) Address-based free list ordering (d) Next-fit free block search

  1. Which of the following is not a UNIX I/O system call?

(a) pipe (b) socket (c) rio_readn (d) select

  1. Which characteristic of well written code motivates the use of large cache blocks?

(a) temporal locality (b) spatial locality (c) small function size (d) minimal coupling

  1. What is a reasonable justification for using multiple processes as a concurrency model for an application instead of multiple threads?

(a) it is easier to share data amongst processes (b) process context switches are more efficient (c) thread concurrency is unpredictable (d) a single misbehaved thread may crash the entire application

  1. Which is the best argument against using multiplexed I/O for a concurrent server?

(a) the lack of true parallelism (b) the inability to use file descriptors without blocking (c) implicit barriers to data sharing (d) the need to synchronize parallel control flows

Part I (4 points)

The diagram below shows the format of a virtual address. Label it with the fields (indicate their positions) that would be used to determine the following:

VPO : The virtual page offset VPN : The virtual page number TLBI : The TLB index TLBT : The TLB tag

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

The diagram below shows the format of a physical address. Label it with the fields (indicate their positions) that would be used to determine the following:

PPO : The physical page offset PPN : The physical page number CO : The cache block offset CI : The cache set index CT : The cache tag

11 10 9 8 7 6 5 4 3 2 1 0

Part II (8 points)

For the virtual address on this and the following page, fill in the diagrams and tables in parts A-D using the address translation and cache structures described. If a page fault occurs, you should leave parts C and D blank.

Virtual Address: 0x051F

A. Virtual address format 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

B. Address translation Parameter Value VPN 0x TLB Index 0x TLB Tag 0x TLB Hit? (Y/N) Page Fault? (Y/N) PPN 0x

C. Physical address format 11 10 9 8 7 6 5 4 3 2 1 0

D. Physical memory reference Parameter Value Cache offset 0x Cache Index 0x Cache Tag 0x Cache Hit? (Y/N) Cache Byte returned 0x

Problem 3. (12 points):

Consider an allocator that uses an explicit (circular) free list. Each block of memory is double-word aligned, and is prefaced by a header that occupies four words of memory: the first word contains the total block size (including payload and boundary tags) and allocated bit, and the second and third words contain pointers to the beginning of the prior and next free blocks (when the block is free). The fourth word in the header is unused. A footer is also present for each block, and consists of two words: the first contains the size and allocated bit and the second is unused.

The diagram below shows the structure of a block:

Answer the following questions based on this allocator, assuming a word size of 4 bytes. If you need additional space, use the back of this sheet.

  1. Given an incoming malloc request for 100 bytes, what is the minimum size of a free block than can be used to satisfy the request?
  2. Given a pointer curr of type (void *) to the head of a free block, how would you obtain a pointer to the beginning of the next free block in the explicit list?

void *next =

  1. Describe the steps needed to free an allocated block using immediate coalescing and a LIFO free list maintenance policy.
  2. It is proposed that the footer be dropped from each block and deferred coalescing be adopted so as to reduce internal fragmentation. Is this a good idea? Why or why not?

Problem 4. (12 points):

Consider an allocator that uses an implicit free list. Each memory block is word-aligned (4-byte words), with word-sized boundary tags that use their LSBs for the allocated bit and the rest of the bits for storing the size of the block. The allocator performs immediate coalescing, and splits blocks during allocation whenever possible (zero payload is not allowed).

Starting with the heap on the left below, show the resulting heap following each successive call to malloc and free. Use a best-fit allocation policy that starts searching from the bottom of the heap shown. Note that you only need to show header/footer word contents.

Start state:

Addr. Data 0x80005068 0x 0x...5064 โ€” 0x...5060 โ€” 0x...505c โ€” 0x...5058 0x 0x...5054 0x 0x...5050 โ€” 0x...504c โ€” 0x...5048 0x 0x...5044 0x 0x...5040 โ€” 0x...503c โ€” 0x...5038 0x 0x...5034 0x 0x...5030 โ€” 0x...502c โ€” 0x...5028 โ€” 0x...5024 0x 0x...5020 0x 0x...501c โ€” 0x...5018 โ€” 0x...5014 โ€” 0x...5010 โ€” 0x...500c โ€” 0x...5008 โ€” 0x...5004 โ€” 0x80005000 0x

After malloc(6): Addr. Data 0x 0x... 0x... 0x...505c 0x... 0x... 0x... 0x...504c 0x... 0x... 0x... 0x...503c 0x... 0x... 0x... 0x...502c 0x... 0x... 0x... 0x...501c 0x... 0x... 0x... 0x...500c 0x... 0x... 0x

After malloc(23): Addr. Data 0x 0x... 0x... 0x...505c 0x... 0x... 0x... 0x...504c 0x... 0x... 0x... 0x...503c 0x... 0x... 0x... 0x...502c 0x... 0x... 0x... 0x...501c 0x... 0x... 0x... 0x...500c 0x... 0x... 0x

After free(0x8000504C): Addr. Data 0x 0x... 0x... 0x...505c 0x... 0x... 0x... 0x...504c 0x... 0x... 0x... 0x...503c 0x... 0x... 0x... 0x...502c 0x... 0x... 0x... 0x...501c 0x... 0x... 0x... 0x...500c 0x... 0x... 0x