Operating Systems 2014F: Tutorial 5: Difference between revisions

From Soma-notes
Line 67: Line 67:
  paging-linear-translate.py -P 1k -a 16k -p 32k -v -u 100
  paging-linear-translate.py -P 1k -a 16k -p 32k -v -u 100
What happens as you increase the percentage of pages that are allocated in each address space?
What happens as you increase the percentage of pages that are allocated in each address space?
* Now let’s try some different random seeds, and some different (and
* Now let’s try some different random seeds, and some different (and sometimes quite crazy) address-space parameters, for variety:
sometimes quite crazy) address-space parameters, for variety:
  paging-linear-translate.py -P 8 -a 32 -p 1024 -v -s 1
  paging-linear-translate.py -P 8 -a 32 -p 1024 -v -s 1
  paging-linear-translate.py -P 8k -a 32k -p 1m -v -s 2
  paging-linear-translate.py -P 8k -a 32k -p 1m -v -s 2

Revision as of 16:32, 3 October 2014

In this tutorial you will be going through homework exercises from the textbook. Be sure to look at the associated chapter if you have questions.

Note there are a lot of material here. Do not expect to do all of it in detail in tutorial; instead, try to do some of everything so you can see where have significant conceptual gaps. On your own you should do these exercises in more detail to make sure you understand the associated concepts.

Relocation

Use the program relocation.py to answer the following questions from the Address Translation chapter. There is also a video available.

  • Run with seeds 1, 2, and 3, and compute whether each virtual address generated by the process is in or out of bounds. If in bounds,

compute the translation.

  • Run with these flags:
-s 0 -n 10

What value do you have set -l (the bounds register) to in order to ensure that all the generated virtual addresses are within bounds?

  • Run with these flags:
-s 1 -n 10 -l 100

What is the maximum value that bounds can be set to, such that the address space still fits into physical memory in its entirety?

  • Run some of the same problems above, but with larger address spaces (-a) and physical memories (-p).
  • What fraction of randomly-generated virtual addresses are valid, as a function of the value of the bounds register? Make a graph from running with different random seeds, with limit values ranging from 0 up to the maximum size of the address space.

Segmentation

Use the program segmentation.py to answer the following questions from the Segmentation chapter.

  • First let’s use a tiny address space to translate some addresses. Here’s a simple set of parameters with a few different random seeds; can you translate the addresses?
segmentation.py -a 128 -p 512 -b 0 -l 20 -B 512 -L 20 -s 0
segmentation.py -a 128 -p 512 -b 0 -l 20 -B 512 -L 20 -s 1
segmentation.py -a 128 -p 512 -b 0 -l 20 -B 512 -L 20 -s 2
  • Now, let’s see if we understand this tiny address space we’ve constructed (using the parameters from the question above). What is

the highest legal virtual address in segment 0? What about the lowest legal virtual address in segment 1? What are the lowest and highest illegal addresses in this entire address space? Finally, how would you run segmentation.py with the -A flag to test if you are right?

  • Let’s say we have a tiny 16-byte address space in a 128-byte physical memory. What base and bounds would you set up so as to get the simulator to generate the following translation results for the specified address stream: valid, valid, violation, ..., violation, valid, valid? Assume the following parameters:
segmentation.py -a 16 -p 128 -A 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 --b0 ? --l0 ? --b1 ? --l1 ?
  • Assuming we want to generate a problem where roughly 90% of the

randomly-generated virtual addresses are valid (i.e., not segmentation violations). How should you configure the simulator to do so? Which parameters are important?

  • Can you run the simulator such that no virtual addresses are valid? How?


Free Space

Use the program malloc.py to answer the following questions from the Free-Space Management chapter.

  1. First run with the flags -n 10 -H 0 -P BEST -s 0 to generate a few random allocations and frees. Can you predict what alloc()/free() will return? Can you guess the state of the free list after each request? What do you notice about the free list over time?
  2. How are the results different when using a WORST fit policy to search the free list (-p WORST)? What changes?
  3. What about when using FIRST fit (-p FIRST)? What speeds up when you use first fit?
  4. For the above questions, how the list is kept ordered can affect the time it takes to find a free location for some of the policies. Use the different free list orderings (-l ADDRSORT, -l SIZESORT+, -l SIZESORT-) to see how the policies and the list orderings interact.
  5. Coalescing of a free list can be quite important. Increase the number of random allocations (say to -n 1000). What happens to larger allocation requests over time? Run with and without coalescing (i.e., without and with the -C flag). What differences in outcome do you see? How big is the free list over time in each case? Does the ordering of the list matter in this case?
  6. What happens when you change the percent allocated fraction -P to higher than 50? What happens to allocations as it nears 100? What about as it nears 0?
  7. What kind of specific requests can you make to generate a highly-fragmented free space? Use the -A flag to create fragmented free lists, and see how different policies and options change the organization of the free list.

Paging

Use the program paging-linear-translate.py to answer the following questions from the Paging: Introduction chapter.

  • Before doing any translations, let’s use the simulator to study how linear page tables change size given different parameters. Compute the size of linear page tables as different parameters change. Some suggested inputs are below; by using the -v flag, you can see how many page-table entries are filled.
    First, to understand how linear page table size changes as the address space grows:
paging-linear-translate.py -P 1k -a 1m -p 512m -v -n 0
paging-linear-translate.py -P 1k -a 2m -p 512m -v -n 0
paging-linear-translate.py -P 1k -a 4m -p 512m -v -n 0

Then, to understand how linear page table size changes as page size grows:

paging-linear-translate.py -P 1k -a 1m -p 512m -v -n 0
paging-linear-translate.py -P 2k -a 1m -p 512m -v -n 0
paging-linear-translate.py -P 4k -a 1m -p 512m -v -n 0

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?

  • Now let’s do some translations. Start with some small examples, and change the number of pages that are allocated to the address space with the -u flag. For example:
paging-linear-translate.py -P 1k -a 16k -p 32k -v -u 0
paging-linear-translate.py -P 1k -a 16k -p 32k -v -u 25
paging-linear-translate.py -P 1k -a 16k -p 32k -v -u 50
paging-linear-translate.py -P 1k -a 16k -p 32k -v -u 75
paging-linear-translate.py -P 1k -a 16k -p 32k -v -u 100

What happens as you increase the percentage of pages that are allocated in each address space?

  • Now let’s try some different random seeds, and some different (and sometimes quite crazy) address-space parameters, for variety:
paging-linear-translate.py -P 8 -a 32 -p 1024 -v -s 1
paging-linear-translate.py -P 8k -a 32k -p 1m -v -s 2
paging-linear-translate.py -P 1m -a 256m -p 512m -v -s 3

Which of these parameter combinations are unrealistic? Why?

  • Use the program to try out some other problems. Can you find the limits of where the program doesn’t work anymore? For example, what happens if the address-space size is bigger than physical memory?

Threads (Intro)

Use the program x86.py (v1) to answer the following questions from the Concurrency: An Introduction chapter.


Locks

Use the program (v2) to answer the following questions from the Locks chapter.