CS 110 Homework Assignment 4
Due: Friday, April 26, 2002, at 9 PM

Turn in your assignments in the bin outside Geoff's office. Late homework will be penalized; see the late policy for more information. We also will not accept handwritten material or printouts in which long lines are wrapped in the middle of a word. We prefer that you use a text processor. You might try troff or latex in combination with xfig.

  1. 4 points:
    Some SPARC implementations feature "out-of-order execution," in which physically later instructions can execute before physically earlier ones under some circumstances. Consider the following SPARC instruction sequence:
    	ld	x, %l2
    	ld	y, %l1
    	ld	z, %l0
    a:	add	%l0, %l1, %l3
    b:	add	%l2, %l1, %l4
    
    Here, the instruction labeled "b" might execute before the one labeled "a" because the value of z might not yet be available from memory (due to pipelining). Suppose "b" is executed first, and a trap occurs after it executes but before "a" executes.
    1. Is this a precise or an imprecise trap?
    2. If the operating system wished to continue the program after servicing the trap, what would it have to do?
  2. 4 points:
    Consider a computer with a 6-bit word length. What does the binary value 101010 represent in each of the following numbering systems?
    1. Unsigned
    2. Sign-magnitude
    3. Two's complement
    4. One's complement
  3. 3 points:
    Explain the difference between internal and external fragmentation.
  4. 5 points:
    Given memory partitions of 100K, 500K, 200K, 300K, and 600K (in order), how would each of the first-fit, best-fit, and worst-fit algorithms place processes of 212K, 417K, 122K, and 426K (in order)? Which algorithm makes the most efficient use of memory?
  5. 5 points:
    Consider a logical address space of eight pages of 1024 words each, mapped onto physical memory of 32 frames.
    1. How many bits are there in the logical address?
    2. How many bits are there in the physical address?
  6. 4 points:
    Supermarkets are constantly faced with a problem similar to page references in virtual memory systems. They have a fixed amount of shelf space to display an ever-increasing number of products. If an important new product comes along, such as 100% efficient dog food, some existing product must be dropped from the inventory to make room for it. The obvious replacement algorithms are LRU and FIFO. Which of these would you prefer, and why?

Last modified April 19, 2002 by geoff@cs.hmc.edu