Virtual Memory Three - Operating Systems - Lecture Slides, Slides of Computer Science

These are the Lecture Slides of Operating Systems which includes File-System Structure, Defining, Logical File, Physical Device, Secondary, System Organized, File Control Block, Structure Consisting, Typical File Control Block etc.Key important points are: Virtual Memory Two, Execution Behavior, Principle of Locality, Program and Data References, Few Pieces, Short Period of Time, Future, Virtual Memory, Physical Addresses, Contiguously

Typology: Slides

2012/2013

Uploaded on 03/28/2013

ekana
ekana 🇮🇳

4

(44)

370 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Operating Systems
Lecture 24:
Virtual Memory (cont)
1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Virtual Memory Three - Operating Systems - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Operating Systems

Lecture 24:

Virtual Memory (cont)

1

Ryan?

2

Clock Policy

• Uses and additional bit called a “use bit”

• When a page is first loaded in memory or

referenced, the use bit is set to 1

• When it is time to replace a page, the OS

scans the set flipping all 1’s to 0

• The first frame encountered with the use bit

already set to 0 is replaced.

5

Clock Policy

Algorithmically identical with another algorithm called “2nd^ chance”.

Only the implementation is different.

7

The 2

nd

Chance Algorithm

  • Holds a FIFO list of pages, each page has a bit R=1 if referenced.
  • Evict the oldest page not referenced in last tick.
  • Repeat while oldest has R=1:
    • Move to end of list (as if just paged in)
    • Set R=
  • At worst, all pages have R=1, so degenerates to regular FIFO.
  • Page list if fault occurs at time 20, A has R bit set (numbers above pages are loading times)

8

The Clock Page Replacement Alg

  • The clock algorithm on 2 bits: referenced R and modified M
  • Hardware sets corresponding R on every memory reference
  • At process start, M and R set to 0
  • Each circular pass, R bits set to 0.
  • Pages are classified
    1. not referenced, not modified
    2. not referenced, modified
    3. referenced, not modified
    4. referenced, modified
  • NRU removes page from lowest- numbered non-empty class

Combined Examples

Comparison

Results based on the execution of 0.25 x 10^6 references in a FORTRAN program, using

a page size of 256 words. It is assumed that the number of page frames assigned to a

process is fixed.

13

Thrashing

• If a process does not have “enough” pages, the page-

fault rate is very high. This leads to:

  • low CPU utilization
  • operating system thinks that it needs to increase the

degree of multiprogramming

  • another process added to the system

• Thrashing ≡ a process is busy swapping pages in and

out

14

Thrashing (Cont.)

16

Allocation of Frames

• Each process needs minimum number of pages

• Example: 6 pages needed by one instruction

  • instruction might span 2 pages
  • 1 st^ argument spans 2 pages
  • 2 nd^ argument spans 2 pages

• Major allocation schemes

  • Fixed vs. Priority allocation
  • Global vs. Local allocation

17

Fixed Allocation

• Equal allocation: e.g, 100 frames and 5

processes, give each process 20 frames.

• Proportional allocation – Allocate according to

the size of process

m S

s a p

m

S s

s p

i i i

i

i i

= = ×

allocation for

totalnumber of frames

sizeofprocess

2

1

2

= × ≈

= × ≈

a

a

s

s

m

i

19

Global vs. Local Allocation

• Global replacement – process selects a

replacement frame from the set of all

frames; one process can take a frame from

another

• Local replacement – each process selects

from only its own set of allocated frames

20

  • A, B, C processes in memory
  • Process A page faults requesting A6.
  • LRU used

Global vs. Local Allocation

(cont)

Time last reference