| MUSO | About FIT2022 | Assessment | Contacts | Laboratories | Lectures | Resources | Timetables | Tutorials |
| Last modified: 20071002:083847/added missing parentheses to eval function in paging.py | FIT2022 AJH-2007-18 |
Objectives | The Banker's algorithm | Page Replacement | Any Questions? | Submitting your Work
Please note the correction to the eval function in the paging.py driver process!
The objectives of this assignment are to:
A pdf version of this assignment sheet is also available.
Consider the following system snapshot, with resources A, B, C and D and processes P0 to P4:
| Max | Allocation | Need | Available | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| A | B | C | D | A | B | C | D | A | B | C | D | A | B | C | D | |
| P0 | 0 | 0 | 1 | 2 | 0 | 0 | 1 | 2 | ||||||||
| P1 | 2 | 7 | 5 | 0 | 2 | 0 | 0 | 0 | ||||||||
| P2 | 6 | 6 | 5 | 6 | 0 | 0 | 3 | 4 | ||||||||
| P3 | 4 | 3 | 5 | 6 | 2 | 3 | 5 | 4 | ||||||||
| P4 | 0 | 6 | 5 | 2 | 0 | 3 | 3 | 2 | ||||||||
| 2 | 1 | 0 | 0 | |||||||||||||
Using the Banker's algorithm, answer the following questions:
You are to write a Python program to model a range of page replacement algorithms. The program should be structured in such a way that each algorithm can be dynamically loaded and executed, to see the effect of using different algorithms on the same page reference string.
Each page replacement algorithm shares a number of common methods. You are to write a superclass, PRA, contained in a file PRA.py, that has the following variables/methods (besides the usual initialization, etc..):
Each of the following algorithms must inherit from PRA.
The frame selected for removal is the oldest page amongst all those in main memory. Write a python class fifo (in a file called fifo.py) that inherits from PRA and implements first-in first-out.
The frame selected for removal is that frame that has not been referenced for the longest period. Write a python class lru (in a file called lru.py) that inherits from PRA and implements least recently used.
The frame selected for removal is that frame that has had the fewest references (since being loaded) of all frames in memory. Use FIFO to break any ties. Write a python class liu (in a file called liu.py) that inherits from PRA and implements least intensively used.
Your main program is responsible for implementing all the tests required under section "Testing your Page Replacement Program" below. Arrange your main program to test both the given reference string, followed by at least two reference strings (with the same parameter) generated by the page reference generator, given in the next section.
A key aspect of your main program is that it must dynamically load the code for each of the three replacement algorithms. That is, they should not be statically included in the code for the main program, but rather, read in at run-time as a string (from the various files), and then evaled to define the appropriate class. The name of the file should be used to determine the class to instantiate.
The algorithms to test must be defined by a list, which (as an extension exercise) can be augmented to add other replacement algorithms if desired.
Your main program should therefore contain the following fragments (or similar - feel free to use eval/exec/execfile as appropriate, or to structure the body of the for loop in whatever way you wish - the only essential thing is that the replacement methods must be called dynamically, as per the # invoke the ref method dynamically line:
"paging.py" 3.1 =Note that the original form of this assignment was published without the empty parentheses in the eval function. These are required to actually instantiate the class.
The following code is provided to assist you in your testing.
"pagerefgen.py" 3.2 =This program can either be used stand-alone to generate a string of page references, or imported into another python program to generate a list of page references. In the latter case, the usage is through calling the function generate(n,l), where n is the number of pages in the logical address space, and l is the length of the generated reference list.
You should run your paging.py program with at least the following reference string on your three algorithms:
3 4 6 8 7 5 1 3 1 5 6 0 4 5 2 7 4 3 2 7 0 3 3 6 3
You should test your algorithms for memory sizes of 3,4,5 frames, and show the results in a pdf file replacement.pdf. Comment on the differences in results in your discussion.
If there is anything unclear, or something you think is needed is omitted, ask your question in the Anonymous Feedback Page and it will be answered as soon as possible.
MOST IMPORTANT! Your work is to be submitted through MUSO as a tar file (uncompressed). The tar file should be named 12345678.tar, where 12345678 is your student ID number. It should contain
and please, NO Word, rar, or zip files!!
Your work will be marked according to the following schema, which will be returned as an attachment under MUSO:
"marks.txt" 5.1 =| 20071002:083847 | 1.0.4 | ajh | added missing parentheses to eval function in paging.py |
| 20070926:145440 | 1.0.3 | ajh | added marking scheme |
| 20070926:122613 | 1.0.2 | ajh | added clarification about PRA class and file |
| 20070829:143426 | 1.0.1 | ajh | added dynamic loading details |
| 20070828:121402 | 1.0.0 | ajh | first version released - not complete |
| This page maintained by John Hurst. Copyright Monash University Copyright Policy |
|
|
|
Generated at
20100314:1835
from an XML file modified on
20071002:0846 | |||