Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Jeliot, execute the following algorithm which implements a buffer pool algorithm. The algorithm offers options for three different heuristics including LRU, LFU, and FIFO.

Using Jeliot, execute the following algorithm which implements a buffer pool algorithm. The algorithm offers options for three different heuristics including LRU, LFU, and FIFO.

import Prog1Tools.IOTools; import java.util.*; class replacepage { public static void main(String args[]) { boolean flag; int f, page=0, ch, pgf=0, n, chn=0, k, pt; int pages[]; //pgf-page fault System.out.println("Menu 1.FIFO 2. LRU 3. LFU"); System.out.println("ENTER YOUR CHOICE: "); Scanner in = new Scanner(System.in); ch = in.nextInt(); switch(ch) { case 1: pt=0; System.out.println("enter no. of buffers (available buffers in the pool): "); f=in.nextInt(); int buffer[]=new int[f]; for(int i=0;i

case 2: k=0; System.out.println("enter no. of buffers (available buffers in the pool): "); f=in.nextInt(); int buffer1[]=new int[f]; int a[]=new int[f]; int b[]=new int[f]; for(int i=0;i

for(int i=0;i

} for(int j=0;j

The algorithm will request the following information to be entered.

Menu: 1. FIFO, 2. LRU, 3. LFU

It would be recommended that you increase the execution speed of Jeliot to its maximum or run this java routine directly from the java interpreter due to the complexity of the code. You can slow down the execution, if required, to understand elements of the execution.

For this assignment you must run the algorithm for each menu option as specified and respond to the questions.

For option 1 on the menu (FIFO), run the algorithm and observe how the algorithm responds. For this iteration use the following input:

Buffers: 2 (the size of the buffer pool)

Pages: 6 (the number of items to place into the pool. Note that there are more pages than frames which means that the algorithm will force some pages out of the buffer pool)

Page Values: 5, 5, 5, 10, 20, 5

Questions:

1. Describe the heuristic used in menu option 1.

2. Under what condition will this heuristic not be efficient? In this context an efficient buffer, is one that has the highest potential to provide a block of data out of the buffer and not have to go back to disk. In your answer consider whether this heuristic is the most effective approach is the value 5 is used more frequently than any other value.

3. Describe a situation where this heuristic would be efficient. For a hint think about read-ahead capabilities.

For option 2 on the menu (LRU), run the algorithm and observe how the algorithm responds. For this iteration use the following input:

Buffers: 2

Pages: 6

Page Values: 5, 10, 5, 10, 20, 5

Questions:

1. Describe the heuristic used in menu option 2.

2. Provide an example or define the characteristics of a situation where this heuristic would be efficient. In this context, efficient, means a situation where required the data can be supplied from the buffer and not from an external source such as the disk. A hint is to look at what data occurs most frequently. In this case it is the value 5.

For option 3 on the menu (LFU), run the algorithm twice and observe how the algorithm responds. For the first iteration of this option use the following input:

Buffers: 2

Pages: 6

Page Values: 5, 10, 5, 10, 20, 5

For the second iteration of this option use the following input:

Buffers: 2

Pages: 6

Page Values: 5, 10, 20, 25, 30, 35

Questions:

1. Describe the heuristic used in menu option 3.

2. What happens when no integer is repeated in the input page values?

3. Describe what happens in the buffer pool when a value is repeated in the page values.

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

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions