Starting from:

$25

CP386- Assignment 3 Solved

For assignment 3, the task was to implement two simplified page fault handlers for an OS.

My program reacts to the sequence of the virtual page references provided on the standard input, and implements:

-a local page replacement algorithm using Clock replacement strategy

-a global page replacement algorithm using FIFO strategy

A virtual page reference has the following format:

<process id> <VPNumber> where

<process id> is a positive integer, unique for each process.

<VPNumber> is a nonnegative integer.

The first line of input contains the word LOCAL or GLOBAL. The second line of input contains an integer M > 2 (number of frames given to a single process for use in local replacements, or total number of frames in the system in global replacement).

Here is an example of several first lines of the input:

LOCAL

3

1 0 \\ process 1 generates access to Virtual Page 0

1 1 \\ process 1 generates access to VP 1

4 \\ process 1 generates access to VP 4
0 \\ process 2 generates access to VP 0 1 0 \\ process 1 generates access to VP 0
1 4 \\ ...

2 1
3 0

...

My page fault handler updates process page tables if a particular page reference is a page fault. It will also accumulate information on the number of page faults per process. When all lines of the input are processed (an empty line is the signal of the end of input), it prints the following information for  each process:

<process id> <Number of Page faults> as well as the contents of each process page table (valid entries only) at the end of processing.

It is assumed that:

Process numbers appearing in the input are in the subset of {1, 2, . . . , k}, but it cannot be assumed that all process numbers are used, and no particular value of k can be assumed.
Frame numbers are 0, 1, 2, ...
All frames are free at the beginning.
In the case of local replacement, there are enough free frames to admit all processes mentioned in the input.
For example, if the input is:

LOCAL

3

3 0

3 1

3 2
2 0
2 1 2 2 my program will print:

PID Page Faults

3
3
Process 2 page table

P# F#

3
4
5
Process 3 page table

P# F#

0
1
2
 

If the same input starts with line GLOBAL, my program will print the following:

PID Page Faults

2 3
3 3

Process 2 page table
P# F#

0
1
2
Process 3 page table

P# F#

More products