Assignment 4 on Operating Systems | CS 570, Assignments of Operating Systems

Material Type: Assignment; Professor: Roch; Class: OPERATING SYSTEMS; Subject: Computer Science; University: San Diego State University; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 03/28/2010

koofers-user-bgz
koofers-user-bgz 🇺🇸

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 570 OPERATING SYSTEMS
ARIE OCH
MR
Assignment 4
Part I must be done individually. Part II may be done with a pair programmer if desired.
As with all assignments in this class, qualitative questions should be answered with
grammatically correct sentences.
Due, Monday, May 5th at the beginning of class.
Part I – Questions, 20 points each
1. Assume we have a paged memory with an address translation cache (ATC)
whose access time is 20 ns and a one-level page table. Suppose that memory
access time is 100 ns. What must the ATC hit rate be for processes to have an
effective access time of no more than 122 nanoseconds? (Hint: Think about
how you determine effective access time. This is just an algebra problem.)
2. Assume a 16 bit address space with a 12 bit page size. Suppose that the
following processes are loaded as follows where 0xN -> 0xM means that
logical page 0xN is loaded into frame 0xM:
o P1: 0x9 -> 0x0, 0xA -> 0x4, 0x8 -> 0xA
o P2: 0x6 -> 0x1, 0x7 -> 0xB, 0x8 -> 0xC, 0x9 -> 0xE
o P3: 0x1 -> 0x2, 0x2 -> 0x3.
Create an inverted page table for the above set of processes assuming that
there are 0x10000 bytes of RAM.
3. Compare the efficiency of prepending and postpending blocks (adding to the
front or end of a file) to files in linked and indexed file systems.
Part II – POSIX programming assignment 120 points
In this assignment, you will construct a simulation of an N-level page tree. Your program
will read a file consisting of memory accesses for a single process, construct the tree, and
assign frame indices to each page. Once all of the addresses have been specified, the
pages which are in use will be printed in order. You will assume an infinite number of
frames are available and need not worry about a page replacement algorithm. See
section functionality for details.
Specification
A 32 bit logical address space is assumed. The user will indicate how many bits are to be
used for each of the page table levels, and a user-specified file containing hexadecimal
addresses will be used to construct a page table.
Mandatory interfaces and structures:
pf3
pf4
pf5

Partial preview of the text

Download Assignment 4 on Operating Systems | CS 570 and more Assignments Operating Systems in PDF only on Docsity!

CS 570 OPERATING S YSTEMS

MARIE ROCH

Assignment 4

Part I must be done individually. Part II may be done with a pair programmer if desired. As with all assignments in this class, qualitative questions should be answered with grammatically correct sentences.

Due, Monday, May 5 th^ at the beginning of class.

Part I – Questions, 20 points each

  1. Assume we have a paged memory with an address translation cache (ATC) whose access time is 20 ns and a one-level page table. Suppose that memory access time is 100 ns. What must the ATC hit rate be for processes to have an effective access time of no more than 122 nanoseconds? (Hint: Think about how you determine effective access time. This is just an algebra problem.)
  2. Assume a 16 bit address space with a 12 bit page size. Suppose that the following processes are loaded as follows where 0xN -> 0xM means that logical page 0xN is loaded into frame 0xM:

o P1: 0x9 -> 0x0, 0xA -> 0x4, 0x8 -> 0xA o P2: 0x6 -> 0x1, 0x7 -> 0xB, 0x8 -> 0xC, 0x9 -> 0xE o P3: 0x1 -> 0x2, 0x2 -> 0x3.

Create an inverted page table for the above set of processes assuming that there are 0x10000 bytes of RAM.

  1. Compare the efficiency of prepending and postpending blocks (adding to the front or end of a file) to files in linked and indexed file systems.

Part II – POSIX programming assignment 120 points

In this assignment, you will construct a simulation of an N-level page tree. Your program will read a file consisting of memory accesses for a single process, construct the tree, and assign frame indices to each page. Once all of the addresses have been specified, the pages which are in use will be printed in order. You will assume an infinite number of frames are available and need not worry about a page replacement algorithm. See section functionality for details.

Specification

A 32 bit logical address space is assumed. The user will indicate how many bits are to be used for each of the page table levels, and a user-specified file containing hexadecimal addresses will be used to construct a page table. Mandatory interfaces and structures:

ƒ unsigned int LogicalToPage(unsigned int LogicalAddress, unsigned int Mask, unsigned int Shift) - Given a logical address, apply the given bit mask and shift right by the given number of bits. Returns the page number, and can be used to access the page number of any level by supplying the appropriate parameters. Example: Suppose the level two pages occupied bits 22 through 27, and we wish to extract the second level page number of address 0x3c654321. LogicalToPage(0x3c654321, 0x0FC00000, 22) should return 0x31 (decimal 49).

ƒ PAGETABLE – Top level descriptor describing attributes of the N level page table and containing a pointer to the level 0 page structure.

ƒ LEVEL – An entry for an arbitrary level, this is the structure (or class) which represents one of the sublevels.

ƒ MAP – A structure containing information about the mapping of a page to a frame, used in leaf nodes of the tree.

You are given considerable latitude as to how you choose to design these data structures. A sample data structure and advice on how it might be used is given here.

ƒ MAP * PageLookup(PAGETABLE *PageTable, unsigned int LogicalAddress) - Given a page table and a logical address, return the appropriate entry of the page table. You must have an appropriate return value for when the page is not found (e.g. NULL if this is the first time the page has been seen). Note that if you use a different data structure than the one proposed, this may return a different type, but the function name and idea should be the same. Similarly, If PageLookup was a method of the C++ class PAGETABLE, the function signature could change in an expected way: MAP * PAGETABLE::PageLookup(unsigned int LogicalAddress). This advice should be applied to other page table functions as appropriate.

ƒ void PageInsert(PAGETABLE *PageTable, unsigned int LogicalAddress, unsigned int Frame) - Used to add new entries to the page table. Frame is the frame index which corresponds to the logical address. If you wish, you may replace void with int or bool and return an error code if unable to allocate memory for the page table. HINT: If you are inserting a page, you do not automatically add nodes, they may already exist at some or all of the levels.

ƒ All other interfaces may be developed as you see fit.

Your assignment must be split into multiple files (you may group by functionality) and you must have a Makefile which compiles the program when the user types "make". Typing make in your directory MUST generate an executable file called "pagetable".

The traces were collected from a Pentium II running Windows 2000 and are courtesy of the Brigham Young University Trace Distribution Center. The files byutr.h and

When the address translation is specified, each logical address and the corresponding physical address should be output with one address pair per line. Write the numbers as 8 digit zero padded hexadecimal numbers separated by “ -> ”. As an example: 60f74100 -> 00000100 0041f780 -> 00007780 0041f740 -> 00007740

To output the page table, form the page number for valid pages as if it was a 1 level table. As an example from a 3 level page table, if level 0 is 4 bits, level 1 is 8 bits and level 2 is 4 bits, an entry for level 0 page 0x3, level 1 0xCC, level 2 page D which maps to frame 3 would be: 00003CCD -> 00000003

Test Cases and Output

Turn in summaries from 3 runs:

  1. pagetable ~mroch/lib/cs570/trace/gcc_integ.tr 20
  2. pagetable ~mroch/lib/cs570/trace/gcc_integ.tr 4 8 8
  3. pagetable ~mroch/lib/cs570/trace/gcc_integ.tr 4 4 12

Answer the following questions:

  1. Compare the memory consumption between the runs. Which was the best? Will it always be the best?
  2. If you implemented your program correctly, question 1 and 3 should have the same hit/miss rate. Will this always be the case regardless of the memory access pattern?

What to turn in

Pair programmers should turn in a single package containing separately answered questions from Part I and the common items for Part II. You must turn in:

  1. Questions from part I.
  2. Answers to questions in Test Cases and Output section and the summary (don’t include the address translation) for the requested runs.
  3. Paper copy of your work including the program, Makefile, and output.
  4. All students must fill out and sign either the single or pair affidavit and attach it to your work. A grade of zero will be assigned if the affidavit is not turned in.
  5. An electronic submission of programs shall be made in addition to the paper copy. A program comparison algorithm will be used to detect cases of program plagiarism. Do not submit your executable or object files.

Remember that all assignments are due at the beginning of class, and the policy on late assignments is described in the syllabus.