Difference between revisions of "Operating Systems 2014F: Tutorial 5"

From Soma-notes
Jump to navigation Jump to search
Line 37: Line 37:
==Free Space==
==Free Space==


Use the program [http://pages.cs.wisc.edu/~remzi/OSTEP/Homework/HW-Freespace.tgz freespace.py] to answer the following questions from the [http://www.cs.wisc.edu/~remzi/OSTEP/vm-freespace.pdf Free-Space Management] chapter.
Use the program [http://pages.cs.wisc.edu/~remzi/OSTEP/Homework/HW-Freespace.tgz malloc.py] to answer the following questions from the [http://www.cs.wisc.edu/~remzi/OSTEP/vm-freespace.pdf Free-Space Management] chapter.


# 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?
# How are the results different when using a WORST fit policy to search the free list (-p WORST)? What changes?
# What about when using FIRST fit (-p FIRST)? What speeds up when you use first fit?
# 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.
# 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?
# 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?
# 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==
==Paging==

Revision as of 12:27, 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?

  1. 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?
  2. 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.


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.