Search for question
Question

1

2

ARLINGTON.

Project 1: Page Replacement

Policy and Buffer Hit Ratio

Talk Outline

Lab

Overview

> Buffer Manager

> Page Replacement Policies

> Buffer Hit Ratio

> Fixing compilation Errors

> Conclusion

Lab

2/n3

In this project, you must implement the

• replacement policies given to you.

• Buffer hit ratio

• Top K page references

Overview

The buffer manager code is given to you.

> DiskMgr and other codes are given to you as .class files.

Do Not delete any class files given to you.

Buffer Management

UTA

Buffer manager

Buffer Pool Pages

Lab

Lab/n5

6

Buffer manager

When a page is requested, the buffer manager

brings it in and pins it.

If the page is not in the pool:

▪ Chooses an unpinned frame for replacement using

one of the policies

If frame is dirty, write it back to disk and mark it clean.

▪ Read the requested page into the frame.

▪ Pin the page and return it's address.

After the requester finishes:

▪ Set dirty bit if page is modified.

▪ Unpin the page.

Design

Lab

HashMap is used to map current page numbers to

frames for efficient lookups.

Lab

3/n7

8

BuffMgr.java

Public pageld newPage( Page firstpg, int run_size):

• Allocates a set of new pages

▪ Pins that page in the buffer, if the page is available in

some frames

> Public void freePage(Pageld firstid):

▪ This method deallocates a page from disk after

removing it from the buffer, if present

BuffMgr.java

Public void pinPage(Pageld pageno, Page page, boolean

skipRead):

• Checks if the required page is in the buffer and already

pinned, if so, increment pin count of the page

• Else the page is not buffer pool, read the page from disk

using read_page. Note, if there are no free pages, the

replacement policies are used.

> Replace Policy with your class name.

• Example-

- Replacer = new Policy(this)

- Should be Replacer new (this)

-Do this for rest of the codes

Lab

Lab/n9

10

FrameDesc[] frametab

It contains the frame table of the Buffer manager

layer.

You will use this array to implement your replacement

policy

Replacer.java

▪ The states of each frame can be AVAILABLE,

REFERENCED and PINNED

▪ Initially, all the frames will be in AVAILABLE state.

▪ LRU

▪ MRU

Policy.java

You have to implement two of the following policies

for page replacement:

• Clock

▪ Random

• FIFO

Lab

Lab

You must change the name of Policy.java to the

policy you are implementing e.g. Clock.java if you're

implementing clock page replacement policy.

5/n11

12

LRU Page Replacement Policy

Implementin pickVictim and update functions.

Dusta: Structuanes Lங்கிய ே

Private void updat

The fame with fame need to replace an engin

eing the

d

Putte with fame on the lat

>Public int picking

of fasthan

for fami

the fired unned frame and call the update function and

theranda pagare p

MRU Page Replacement Policy

Implementin pickVictim and update function

Data StructureURUMU

Private void updat

The fame with gen fame need to replace an existing fame in fam

thing they

-TTTTT

एवं

Public int pict

the first und an and call the pond

Lab

12

6

Fig: 1

Fig: 2

Fig: 3

Fig: 4

Fig: 5

Fig: 6