• No results found

lecture 23 chapter 4

N/A
N/A
Protected

Academic year: 2020

Share "lecture 23 chapter 4"

Copied!
24
0
0

Loading.... (view fulltext now)

Full text

(1)

07/10/2020 1

discover yourself

inspire posterity

CHAPTER 4

(2)

Optimal Page Replacement Algorithm

1. The optimal page replacement algorithm is an algorithm

when a page needs to be swapped in. The Operating

System swaps out the page whose next use will occur

farthest in the future.

2. Replace page that will not be used for longest period of

time

3. For example, a page that is not going to be used for the

next 6 seconds will be swapped out over a page that is

going to be used within the next 0.4 seconds.

discover yourself

(3)

discover yourself

inspire posterity

EXAMPLE-1

(4)

The first three references cause faults that fill the three empty frames.

The reference to page 2 replaces page 7, because 7 will not be used until

reference 18, whereas page 0 will be used at 5, and page 1 at 14.

The reference to page 3 replaces page 1, as page 1 will be the last of the

three pages in memory to be referenced again.

With only nine page faults, optimal replacement is much better than a FIFO

algorithm, which resulted in fifteen faults.

discover yourself

(5)

discover yourself

inspire posterity

EXAMPLE-2

(6)

discover yourself

inspire posterity

EXAMPLE-3

Apply OPTIMAL ALGORITHM

No. of Frames = 3

(7)

discover yourself

inspire posterity

EXAMPLE-3 SOLUTION

Apply OPTIMAL ALGO

No. of Frames = 3

0 2 4 6 2 0 9 5 3 8 1 7 1 7

(8)

discover yourself

inspire posterity

EXERCISE-1

(9)

Unfortunately, the optimal page-replacement is difficult

to implement, because it requires future knowledge of

the reference string

discover yourself

(10)

Least-Recently-used (LRU) algorithm

LRU replacement associates with each page the time

of that page’s last use

When a page must be replaced, LRU chooses the page

that has not been used for the longest period of time

discover yourself

(11)

discover yourself

inspire posterity

(12)

Notice that the first 5 faults are the same as those for optimal

replacement.

When the reference to page 4 occurs, however, LRU replacement sees

that, of the three frames in memory, page 2 was used least recently.

Thus, the LRU algorithm replaces page 2, not knowing that page 2 is

about to be used.

When it then faults for page 2, the LRU algorithm replaces page 3, since it

is now the least recently used of the three pages in memory.

Despite these problems, LRU replacement with 12 faults is much better than

FIFO replacement with 15.

discover yourself

inspire posterity

(13)

discover yourself

inspire posterity

Least-Recently-used (LRU) algorithm

(14)

discover yourself

inspire posterity

(15)

Comparison of OPT with LRU

Example: A process of 5 pages

discover yourself

(16)

Comparison of FIFO with LRU

LRU recognizes that pages 2 and 5 are referenced

more frequently than others but FIFO does not.

A. Frank - P. Weisberg

discover yourself

(17)

10/07/202

0 17

Not/Least Frequently Used

The not frequently used (NFU) page replacement algorithm

requires a counter, and every page has one counter of its own

which is initially set to 0. At each clock interval, all pages that

have been referenced within that interval will have their

counter incremented by 1. In effect, the counters keep track of

how frequently a page has been used. Thus, the page with the

lowest counter can be swapped out when necessary.

discover yourself

(18)

10/07/202

0 18

discover yourself

inspire posterity

3 7 6 4 6 2 1 9 2 8

Not/Least Frequently Used

(19)

10/07/202

0 19

discover yourself

inspire posterity

(20)

10/07/202

0 20

discover yourself

inspire posterity

7 0 1 2 0 3 0 4 2 3 0 3 2 1 2

Not/Least Frequently Used

(21)

10/07/202

0 21

discover yourself

inspire posterity

(22)

10/07/2020 22

Segmentation

(HOME READING)

A process is divided into number of segments that need not

be of equal size. When a process is brought in, all of its

segments are loaded into available regions of memory and

a segment table is set up.

discover yourself

(23)

10/07/2020 23

PAGING

1. Main memory is divided into small fixed-size chunks called frames.

2. Program is broken down into small chunks called pages, handled by memory management or compiler.

3. no external fragmentation.

4. OS must maintain a page table for each process showing which frame each process occupy.

5. OS must maintain a free frame list.

6. All the pages of a process must be in main memory for process to run.

Segmentation

1. Main memory not partitioned

2. Program is broken down into segments specified by programmer to the compiler. 3. external fragmentation.

4. OS must maintain a segment table for each process showing which frame each process occupy.

5. OS must maintain a free frame list.

6. All the pages of a process must be in main memory for process to run.

discover yourself

(24)

End of Chapter-4

discover yourself

References

Related documents

For personal use only... The generated list of skills contained IV drip insertion, venipuncture, Foley catheterization, lumbar puncture, arterial puncture, nasogas- tric tube

In order to reach the overall objective to observe, analyze and better understand the highly diverse livelihood strategies of vulnerable rural households in the Uplands of Northern

To address this outstanding question, we investigated the mechanical properties of cell surface structures as a function of the concentration of PFA ( C PFA ) by using atomic

Monthly data from January 2000 to April 2014 are used to analyze the impacts of the Industrial Production Index, the money supply, the Pak-US interest rate differential, the

GENERAL: In this chapter, the properties of semi dense bituminous concrete such as stability, flow, air voids (VV), Voids in mineral aggregate (VMA), voids filled

Using the proposed method, faulty ciphertexts that are obtained when faults are injected in the i -th round can be used twice (previous fault attack use those ciphertexts only once

Мне представляется, что если и возможен марксизм сегодня, то как некая эстетическая доктрина… Но и это приключение уже пережито марксизмом… Однако стали бы

Having examined the impact of strategic planning and innovation on organisational performance in the Saudi Red Crescent Authority, this study has the potential to