@www.csse.monash.edu.au |
| Assessment | Contacts | Laboratories | Lectures | Resources | Timetables | Tutorials | Unit Outline |
| Last modified: 20081014:124018/removed reference to pdf version of assignment sheet | FIT2022 AJH-2008-29 |
Objectives | The Banker's algorithm | Page Replacement | Any Questions? | Submitting your Work | Use of SVN
The objectives of this assignment are to:
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 =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 Moodle Forum Page and it will be answered as soon as possible.
Check the Wiki Page for helpful hints.
A marking quide is available (see below).
MOST IMPORTANT! You should submit all your required files as a zipped archive through the Moodle assignment 2 submission mechanism. Name the zip file yourStudentID.zip
It should contain
and please, NO Word, rtf or rar files!!
Your work will be marked according to the following schema, which will be returned as an attachment under Moodle:
"marks.txt" 5.1 =If you wish to use the svn repository, you must use your own private repository, fit2022-yourAuthCateName.zip. Students found using public areas will have their work removed, and they will not receive any marks for the assignment.
| 20081014:124018 | 2.0.4 | ajh | removed reference to pdf version of assignment sheet |
| 20080925:110100 | 2.0.3 | ajh | removed redundant comment re eval function |
| 20080924:165025 | 2.0.2 | ajh | clarified marking scheme document |
| 20080828:163047 | 2.0.1 | ajh | added major content |
| 20080825:100842 | 2.0.0 | ajh | first version for 2008 from ass1 |
| This page maintained by John Hurst. Copyright Monash University Copyright Policy |
|
|
|
Generated at
20100831:2106
from an XML file modified on
20100831:1536 | |||