Question: Your program is required to read in a text le which contains a description of a reference string that will be simulated. The rst line
Your program is required to read in a text le which contains a description of a reference string that will be
simulated. The rst line gives the number of pages for the system, the second gives the number of frames,
and the third line lists the number of page requests aka entries in the reference string. After that, reference
string entries are listed in sequence from to the number indicated. All numbers are positive integers. A
sample data le is attached to this assignment not the one we will grade with and an annotated version is
shown below. You may assume that a reference string contains at most entries.
; number of pages see canvas for the version of this file you need to support
; number of frames
; number of entries in reference string
; th page in reference string
; th page in reference string
;
; th page in reference string
PageTable.h
#ifndef PAGETABLEH
#define PAGETABLEH
#include
#include
enumeration to represent replacement algorithms.
enum replacementalgorithm
FIFO
LRU,
MFU
;
forward declarations for structs
struct pagetableentry;
struct pagetable;
Creates a new page table object. Returns a pointer to created page table.
@param pagecount Number of pages.
@param framecount Numbers of frames.
@param algorithm Page replacement algorithm
@param verbose Enables showing verbose table contents.
@return A page table object.
struct pagetable pagetablecreateint pagecount, int framecount, enum replacementalgorithm algorithm, int verbose;
Destorys an existing page table object. Sets outside variable to NULL.
@param pt A page table object.
void pagetabledestroystruct pagetable pt;
Simulates an instruction accessing a particular page in the page table.
@param pt A page table object.
@param page The page being accessed.
void pagetableaccesspagestruct pagetable pt int page;
Displays page table replacement algorithm, number of page faults, and the
current contents of the page table.
@param pt A page table object.
void pagetabledisplaystruct pagetable pt;
Displays the current contents of the page table.
@param pt A page table object.
void pagetabledisplaycontentsstruct pagetable pt;
#endif
DataLoader.h
#ifndef FILELOADERH
#define FILELOADERH
#include
#include
structs
struct testscenario
int refstrlen;
int refstr;
int pagecount;
int framecount;
;
Loads a testscenario strut from a textfile.
@param filename The name of the file to load.
@return A struct containing the loaded file.
struct testscenario loadtestdatachar filename;
#endif
simulatorc
#include
#include
#include "DataLoader.h
#include "PageTable.h
int mainint argc, char argv
char filename argv;
struct testscenario data loadtestdatafilename;
struct pagetable ptfifo pagetablecreatedatapagecount, dataframecount, FIFO, ;
struct pagetable ptlru pagetablecreatedatapagecount, dataframecount, LRU, ;
struct pagetable ptmfu pagetablecreatedatapagecount, dataframecount, MFU, ;
simulate page requests: fifo
for int i ; i datarefstrlen; i
pagetableaccesspageptfifo, datarefstri;
pagetabledisplaycontentsptfifo;
pagetabledisplayptfifo;
simulate page requests: lru
for int i ; i datarefstrlen; i
pagetableaccesspageptlru, datarefstri;
pagetabledisplaycontentsptlru;
pagetabledisplayptlru;
simulate page requests: mfu
for int i ; i datarefstrlen; i
pagetableaccesspageptmfu, datarefstri;
pagetabledisplaycontentsptmfu;
pagetabledisplayptmfu;
pagetabledestroy&ptfifo;
pagetabledestroy&ptlru;
pagetabledestroy&ptmfu;
freedata;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
