Homeworks

Homeworks are not mandatory; rather, they are things you can do in your own time to see if you have really understood something. The basic idea is simple: each of the programs below let you both generate and get solutions for an infinite number of problems. They are meant to firm up your understanding of some of the basic concepts we discussed in class. In some cases, a few suggested problems are given.

Note: All of these scripts and README files are now available online here as well as in the file system at the path names listed below. Or, just download all the homeworks in one fantastic tarball here.

Homework 1: Scheduling

Available in ~cs537-1/homeworks/scheduler . Read the README file therein and then run scheduler.py to test your knowledge of different scheduling policies and the metrics we use to evaluate them.

Homework 2: Segmentation

Available in ~cs537-1/homeworks/segmentation . Read the README file therein and then run segmentation.py to test your knowledge of how segmentation works and the general process of virtual-to-physical address translation in a simple segmented system.

Some questions: Run the following and see if you can calculate the translations. What do you expect to happen when the limit registers values are increasing? To what values should the limit registers be set in order to avoid any segmentation violations?

./segmentation.py -s 0 -a 64 -p 1024 -b 128 -B 1024 -l 5 -L 5
./segmentation.py -s 0 -a 64 -p 1024 -b 128 -B 1024 -l 10 -L 10
./segmentation.py -s 0 -a 64 -p 1024 -b 128 -B 1024 -l 15 -L 15
./segmentation.py -s 0 -a 64 -p 1024 -b 128 -B 1024 -l 20 -L 20

As compared to dynamic relocation (i.e., one base/bounds pair per address space), how much physical memory is saved in the above example by using segmentation? Could you come up with an equation to determine the answer?

Homework 3: Linear Page Tables (Size)

Available in ~cs537-1/homeworks/paging-linear-size . Read the README and run the program paging-linear-size.py to see if you understand how to compute the size of linear page tables as different parameters change. Some suggested inputs are below. First, to understand how linear page table size changes as the address space grows:

./paging-linear-size.py -v 16 -p 4k
./paging-linear-size.py -v 24 -p 4k
./paging-linear-size.py -v 32 -p 4k
Then, to understand how linear page table size changes as page size grows:
./paging-linear-size.py -v 32 -p 1k
./paging-linear-size.py -v 32 -p 2k
./paging-linear-size.py -v 32 -p 8k
./paging-linear-size.py -v 32 -p 1m
Before running any of these, try to think about the expected trends. How should page-table size change as the address space grows? As the page size grows? Why shouldn't we just use really big pages in general?

Homework 4: Linear Page Tables (Translations)

Available in ~cs537-1/homeworks/paging-linear-translate . Read the README and run the program paging-linear-translate.py to see if you understand how to compute translations from virtual to physical addresses.

Homework 5: Paging Policies

Available in ~cs537-1/homeworks/paging-policy . Read the README and run the program paging-linear-translate.py to see if you understand how the different page-replacement policies work, such as LRU, FIFO, and OPT.

Some examples (from the handout) to compare how OPT, FIFO, and LRU perform:

./paging-policy.py -a 0,1,2,0,1,3,0,3,1,2,1 -p OPT -C 3 ./paging-policy.py -a 0,1,2,0,1,3,0,3,1,2,1 -p FIFO -C 3 ./paging-policy.py -a 0,1,2,0,1,3,0,3,1,2,1 -p LRU -C 3
Or to discover Belady's anomaly (using FIFO, while increasing cache size):
./paging-policy.py -a 1,2,3,4,1,2,5,1,2,3,4,5 -p FIFO -C 3 ./paging-policy.py -a 1,2,3,4,1,2,5,1,2,3,4,5 -p FIFO -C 4

Homework 6: Multi-level Page Tables

Available in ~cs537-1/homeworks/paging-multilevel-translate . Read the README for more details. Stare at memory dumps to figure out how translations actually work for a particular example of a multi-level page table.