Homework 4: Caches and Virtual Memory

Assigned Thursday, February 28, 2013
Due Date Friday, March 8, 2013 at 17:00

Introduction

The purpose of written homework assignments is to get you thinking about the topics being covered in lecture and in readings in the textbook which are not represented in the hands-on, programming lab assignments. These written assignments also better prepare you for course examinations. It is worth noting that the book contains many practice problems similar to the problems we ask on these written assignments. The solutions for those practice problems are located at the end of each chapter and should give you a feel for the kind of answers we expect you to turn in for these kind of assignments.

Logistics

Since these written homeworks are not programming lab assignments, you will turn in your assignment online as electronic documents in PDF format. We will not accept any paper submissions.

Grading

Same rules as for homework #1

We will provide solutions to all of the problems in the written homework assignments in a timely fashion after the assignment is due. Since the late policy affords you a maximum of three late days, we cannot release solutions until the Wednesday following the assignment's due date, at the earliest.

Questions

Answer the following problems from the textbook. If a practice problem is listed, try to solve the problem on your own first, then check your answer at the end of the chapter. Make sure you understand the solution provided, then complete the additional questions below. Your write-up only needs to contain the information necessary to understand your answer to the additional questions - you do NOT need to turn in the answer to the practice problem in its entirety.

  1. Homework Problem 6.37. Review slides 8 and 9 from the Memory and Caches II lecture before working on this problem.
  2. The following program may have different outputs depending on the order that processes run in; list all of the possible outputs. Assume that the fork() call cannot fail.
    
    	int main()
    	{
    		int x = 3;
    
    		if (fork() != 0) {
    			x++;
    			printf("x=%d\n", x);
    		}
    
    		x--;
    		printf("x=%d\n", x);
    		exit(0);
    	}
    	
  3. Practice Problem 9.2. Repeat for: n = 64 and P = 4 KB (e.g. an x86-64 system with standard pages); n = 64 and P = 4096 KB (e.g. an x86-64 system with "huge pages"). Give your answer as a power of 2.
  4. Practice Problem 9.3. Consider a 64-bit virtual address space and a 36-bit physical address; repeat this problem for P = 4 KB and P = 4096 KB.
  5. Homework Problem 9.11. Read and understand the solution to practice problem 9.4 before working on this problem.
  6. Homework Problem 9.12.
  7. Homework Problem 9.13.

Notes

Make sure you are using the 2nd edition of Computer Systems: A Programmer's Perspective. If you're not using the right book, you might be doing the wrong problems!

Submitting Your Work

Please turn in a PDF file containing your answers to the Catalyst Drop Box for this assignment. We will not accept submissions that are not in PDF format.