
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Write function LRU using C to do the following.
a. Return type void
b. Empty parameter list
c. Write a series of printf statements to display the algorithm
name and the output header
d. Declare a one-dimensional array, data type integer, to store the
page requests (i.e., pageRequests) initialized to data set 4, 1,
2, 4, 2, 5, 1, 3, 6
e. Declare a variable, data type integer, to store the page faults,
initialize to 0 (i.e., pageFaults)
f. Declare a one-dimensional array, data type integer, to store the
memory frame a page is allocated to (i.e., allocation), size is
parameter FRAMES
g. Declare a variable, data type integer, to store number of pages
(i.e., pages) initialized to the number of page requests
h. Declare a variable, data type integer, to store page hits (i.e.,
counter)
i. Declare a one-dimensional array, data type integer, to store
when a page is allocated to (i.e., time), size is parameter 10
j. Declare a variable, data type integer, to track page hits/misses
(i.e., flag1)
k. Declare a variable, data type integer, to track page hits/misses
(i.e., flag2)
l. Declare a variable, data type integer, to store the position of
the most recent request, initialize to 0 (i.e., position)
m. Initialize the allocation array by calling function memset,
passing arguments
i. Array allocation
ii. -1 (i.e., INVALID)
iii. sizeof(allocation)
n. Using a looping construct, iterate through the number of pages
i. Set variable flag1 equal to 0
ii. Set variable flag2 equal to 0
iii. Using a looping construct, iterate through the number
of FRAMES
1. If the current page request is equal to the
current frame allocation
a. Increment the counter variable by 1
b. Update array time, index of the loop
control variable, set it equal to variable
counter
c. Set variable flag1 equal to 1
d. Set variable flag2 equal to 1
e. Break out of the loop
iv. If variable flag1 is equal to 0
1. Using a looping construct, iterate through the
number of FRAMES
a. If the current element of array
allocation is equal to a -1 (i.e.,
INVALID)
i. Increment the counter variable
by 1
ii. Increment the pageFaults
variable by 1
initialize to 0 (i.e., pageFaults)
f. Declare a one-dimensional array, data type integer, to store the
memory frame a page is allocated to (i.e., allocation), size is
parameter FRAMES
g. Declare a variable, data type integer, to store number of pages
(i.e., pages) initialized to the number of page requests
h. Declare a variable, data type integer, to store page hits (i.e.,
counter)
i. Declare a one-dimensional array, data type integer, to store
when a page is allocated to (i.e., time), size is parameter 10
j. Declare a variable, data type integer, to track page hits/misses
(i.e., flag1)
k. Declare a variable, data type integer, to track page hits/misses
(i.e., flag2)
l. Declare a variable, data type integer, to store the position of
the most recent request, initialize to 0 (i.e., position)
m. Initialize the allocation array by calling function memset,
passing arguments
i. Array allocation
ii. -1 (i.e., INVALID)
iii. sizeof(allocation)
n. Using a looping construct, iterate through the number of pages
i. Set variable flag1 equal to 0
ii. Set variable flag2 equal to 0
iii. Using a looping construct, iterate through the number
of FRAMES
1. If the current page request is equal to the
current frame allocation
a. Increment the counter variable by 1
b. Update array time, index of the loop
control variable, set it equal to variable
counter
c. Set variable flag1 equal to 1
d. Set variable flag2 equal to 1
e. Break out of the loop
iv. If variable flag1 is equal to 0
1. Using a looping construct, iterate through the
number of FRAMES
a. If the current element of array
allocation is equal to a -1 (i.e.,
INVALID)
i. Increment the counter variable
by 1
ii. Increment the pageFaults
variable by 1
iii. Update the allocation array for
the current frame by setting it
equal to the current
pageRequest
iv. Update array time for the
current frame by setting it equal
to variable counter
v. Set variable flag2 equal to 1
vi. Break out of the loop
v. If variable flag2 is equal to 0
1. Set variable position equal to function call
findLRU passing array time as an argument
2. Increment the counter variable by 1
3. Increment the pageFaults variable by 1
4. Update the allocation array at index position
by setting it equal to the current pageRequest
5. Update array time at index position by setting
it equal to variable counter
vi. Call function displayPages passing arguments
1. the current pageRequest
2. allocation array
o. Display to the console the total number of page faults
the current frame by setting it
equal to the current
pageRequest
iv. Update array time for the
current frame by setting it equal
to variable counter
v. Set variable flag2 equal to 1
vi. Break out of the loop
v. If variable flag2 is equal to 0
1. Set variable position equal to function call
findLRU passing array time as an argument
2. Increment the counter variable by 1
3. Increment the pageFaults variable by 1
4. Update the allocation array at index position
by setting it equal to the current pageRequest
5. Update array time at index position by setting
it equal to variable counter
vi. Call function displayPages passing arguments
1. the current pageRequest
2. allocation array
o. Display to the console the total number of page faults
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- C++ Programming: How would you write a function that takes a filename and an array of struct time, opens a file, reads each line in the file as the number of days, converts this to a struct time and stores this is in an array? Here is my code so far (p.s. the function i need help with is called void readData): #include<iostream>#include<string>#include<fstream>#include<cstdlib>#include<vector> using namespace std; struct time{// private:int years, months, days;//public: time(){}time(int days){}}; time getYearsMonthsDays(int days){time x;x.years = days/450;days = days%450;x.months = days/30;x.days = days%30;return x;} int getTotalDays(time x){int totalDays;totalDays = x.years*450 + x.months*30 + x.days;return totalDays;} void openofile(string ofilename,ofstream &fout){fout.open(ofilename.c_str());if(!fout){cout << "Error opening output file..." << endl;exit(1);}} void openifile(string ifilename,ifstream…arrow_forwarduse c code to develop the condition and function for the following items and then redevelop the code by adding the function as shown below, the original code has been given below. Hint: a)the function need to be made and develop and than add to the code 1. print Reverse 2. void reverseIt 3. void search Array 4.void search array 5. void array copy and void arrayDiff) b) the answer must be include and output and c code void printReverse(int array[], size); //prints the array reverselyvoid reverseIt(int array[], size); //reverses an arrayvoid searchArray(int array[], int size, int num);// returns the first index of the array whose value is num.//returns -1 if the number was not found in the array// optional for lab 6:void searchnArray(int array[], int size, int num, int n);// returns the nth index of the array whose value is num.//returns -1 if the number was not found in the arrayvoid arrayCopy (int arDest[], int arSource[], int commonSize);// copies cells from arSourc to arDestvoid…arrow_forward1. declare an array to hold 12 floating point numbers: 2. Now that we have our array, set all 12 numbers to -100. 3. Change all even positions (all lines with an even index: 0,2,4, etc) to 96.8Use a function call to print the array.arrow_forward
- Which of the following function declarations are wrong? int f(int[][] a, int rowSize, int columnSize); int f(int a[][], int rowSize, int columnSize);int f(int a[][3], int rowSize);arrow_forwardC++ Get a value from the user and using a loop, search for the value in the array. Report all the index locations where it is found Report if it is not found anywhere This is part 4 of an ongoing assignment RandArray which consisted of assigning 20 integers with a random value. I am not sure how to write this out so it matches the output ( in the attached pictures ). I have attached the starter code to this problem as well as my code for part 3 which was correct. Thank you ( STARTER CODE ) #include <iostream>using namespace std; #include <cstdlib> // required for rand() int main(){// Put Part3 code here //Part 4// ask cout << "Enter value to find: ";// look through the array. // If it is found:// print // Found 55 at index 12 // if it is not found after looking at all the elements, // print // 0 is not found in randArray } _______________________________________________________________________ ( PART 3 CODE ) #include <iostream> using…arrow_forward9. Write function getMoveRow to do the following a. Return type integer b. Parameter list i. 1-d character array (i.e. move), size 3 c. Convert the row portion of the player’s move to the associated integer index for the board array d. Example: i. move = ‘b2’ ii. 2 is the row iii. 2 is index 1 in the board array e. Return the row array index that corresponds to the player’s move f. Return a -1 if the row is not valid (i.e. INVALID) 10. Write function getMoveCol to do the following a. Return type integer b. Parameter list i. 1-d character array (i.e. move), size 3 c. Convert the column portion of the player’s move to the associated integer index for the board array d. Example: i. move = ‘b2’ ii. b is the column iii. b is index 1 in the board array e. Return the column array index that corresponds to the player’s move f. Return a -1 if the column is not valid (i.e. INVALID) I am getting an error when entering the code at the very end. please fix it. This is the code in C int…arrow_forward
- Alert: Don't submit AI generated answer and please submit a step by step solution and detail explanation for each steps. Write a python program using functionsarrow_forward13. Write function updateBoard to do the following a. Return type void b. Parameter list i. 1-d character array (i.e. move), size 3 ii. 2-d character array (i.e. board), size 8 rows and 8 cols iii. Structure Player (i.e. player) as a pointer c. Declare local variable rowInt, data type integer, set equal to function call getMoveRow, passing parameter move as an argument d. Declare local variable colInt, data type integer, set equal to function call getMoveCol, passing parameter move as an argument e. If calling function checkHorizontal (i.e. see argument list in step f.i.) is greater than ZERO, call function updateHorizontal, passing as arguments i. rowInt ii. colInt iii. board iv. player f. If calling function checkVertical (i.e. see argument list in step f.ii.) is greater than ZERO, call function updateVertical, passing as arguments i. rowInt ii. colInt iii. board iv. player g. If calling function checkDiagonal (i.e. see argument list in step f.iii.) is greater than ZERO, call…arrow_forwardAHPA #11: Changing Grades * * Create a C function (switcher) that will receive a pointer to the finalExams array, using only pointers look for D scores and boost them to C scores. (ouput should be same as picture)arrow_forward
- a. Problem 1. Create an array of 30 random numbers that range between 1 and 100. Then, write a function that will receive a number from the user and determine if that number exists in the array or not. For instance, assume the array is: [2, 93, 14, 89, 12, 3, 81, 15, 14, 89, 52, 96, 71, 82, 5, 2, 41, 23, 52, 59, 44, 44, 88, 39, 49, 50, 97, 45, 48, 36] Now, assume the user enters 89, the program should output true. But, if the user enters 77, the program should output false. Approach: We will be implementing this method in two different ways. Both will be recursive. First, implement a method called findA (x,A), where x is the number we are looking for and A is an array. In the body of the function, compare x with the FIRST item that is in the array. If this first item is equal to X, return true. If not, remove the first item from A and call findA (x,A) on the revised list. If you call find on an empty list, you will want to return false. Writing any explicit loop in your code results a…arrow_forward6. In NumPy, write a program to show the syntax to print the data type of an array. Take the sample array as [1, 2, 3, 4, 5]arrow_forwardIn the code segment Double radius = 4.5; Const double* ptr = & radius;The ptr is constant, but the data pointed to by the pointer ptr is not constant options: True Falsearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education