Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please implement a Least Recently Used to this program. Langauge is in C++ // Optimal Page Replacement Algorithm - C program #include #define

image text in transcribed

Can you please implement a Least Recently Used to this program. Langauge is in C++

// Optimal Page Replacement Algorithm - C program #include #define MAX_PAGE 25 // Define a constant, program can support only this MAX_PAGE number of pages. #define MAX_FRAME 25 // Define a constant, program can support only this MAX_FRAME number of frames.

int main() { // Declare arrays for pages and frames and distance_from_future_occurance int pages[MAX_PAGE], frames[MAX_FRAME], distances[MAX_PAGE]; // Number of pages, frames, page faults variables int numberPages, numberFrames, numberPageFaults = 0; // Other variables int i, j, temp, flag, found, lastFilledFrame, index, highestDistance; // Get number of frames from user printf("Enter number of frames (max limit is %d): ", MAX_FRAME); scanf("%d", &numberFrames); printf("You provided number of frames: %d ", numberFrames); // Initialize frames array with -1 values and set lastFilledFrame value to -1 for(i = 0; i optimalPage Replacement Algorithm This project consists of implementing the optimal Page Replacement Algorithm on a reference string. As reviewed in class, the optimal Page Replacement Algorithm replaces the page that is not going to be used for the longest period of time. Your program should work as follows: Enter a reference string: 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 (required) Enter the of frames 3 your program should be able to support any of frames) Running simulation: Start: Memory is: 7: Memory is 7 Page Fault (Number of Page Faults: 1) 0: Memory is 7 0 Page Fault (Numbe er of Page Faults: 2) 1: Memory is: 7 0 1: Page Fault: (Number of Page Faults: 3) 2: Memory is 2 0 1: Page Fault: (Number of Page Faults: 4) 0: Memory is: 2 0 1: Hit: (Number of Page Faults 4) 3: Memory is: 2 0 3: Page Fault: (Number of Page Faults: 5) 0: Memory is: 2 0 3: Hit: r of Page Faults: 5) 4: Memory is 2 4 3: Page Fault: (Number of Page Faults 6) 2: Memory is: 2 4 3: Hit: r of Page Faults: 6) 3: Memory is: 2 4 3: Hit: (Number of Page Faults: 6) 0: Memory is: 2 0 3: Page Fault: (Number of Page Faults: 7) 3: Memory is 2 0 3: Hit: (Number of Page Faults: 7) 2: Memory is: 2 0 3: Hit: (Number of Page Faults: 7) 1: Memory is: 2 0 1: Page Fault: (Number of Page Faults: 8) 2: Memory is: 2 0 1: Hit: (Number of Page Faults: 8) 0: Memory is: 2 0 1: Hit: (Number of Page Faults: 8) 1: Memory is 2 0 1 Hit: (Number of Page Faults: 8) 7: Memory is: 7 0 1: Fault: (Number of Page Faults 9) 0 Memory is: 7 0 1: r of Page Faults: 9) 1: Memory is 7 o 1: Hit: (Number of Page Faults: 9) Total Number of Page Faults 9 Extra Credit. You may implement Least Recently Used for Extra Credit. This assignment is due May 1, 2017

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions