• No results found

VIRTUAL MEMORY - 10TH WEEK

N/A
N/A
Protected

Academic year: 2021

Share "VIRTUAL MEMORY - 10TH WEEK"

Copied!
34
0
0

Loading.... (view fulltext now)

Full text

(1)

PROJECT

DATE 4 MAY 2011 CLIENT OPERATING SYSTEM

VIRTUAL MEMORY -

10TH WEEK

(2)

References

Abraham Silberchatz, Peter Baer Galvin, Greg Gagne, “Operating System Concepts with

Java 6th Edition“, Wiley International

Publisher : Chapter 10

http://www.linux.com/news/software/

applications/8208-all-about-linux-swap-space http://www.linuxjournal.com/article/8178

(3)

Outline

Introduction

Virtual Memory Management:

Demand Paging

Copy on Write

Page Replacement
(4)

Outline

Introduction

Virtual Memory Management:

Demand Paging

Copy on Write

Page Replacement
(5)

Characteristics of

User Program

Error Handling, executed not so frequently

Unused allocation for array, lists, and tables - ex. : string name[10000];

Certain features and options are used

rarely

It means, even though all parts of a program are loaded in main memory, we usually
(6)

Memory sharing

We have common library that is used together

No more constraint from physical memory

Run multiple programs at the same time
(7)

Virtual Memory

Virtual memory – separation of user logical memory from

physical memory

Virtual memory allows user to see extremely large logical memory address compared to the ‘real’ physical memory address

Only part of the program needs to be in memory for execution

Allows address spaces to be shared by several processes
(8)
(9)

Virtual Address Space

Known as sparse address space

useful for dynamic memory allocation

(10)

Outline

Introduction

Virtual Memory Management:

Demand Paging

Copy on Write

Page Replacement
(11)

Swapping in Virtual Memory

Swap the whole process (conventional memory

management)

Swap only parts of process (virtual memory)

(12)

Demand Paging

Paged processes are loaded only when they are needed

Lazy swapper: never swaps a page into

memory unless that page will be needed. Thus we use term pager instead of

swapper.

Memory I/O time and physical memory requirement decreases.
(13)

Valid and Invalid Flags

How to know, whether our process is in memory or hard disk?
(14)

Err...what about if you

can’t find your pages in

(15)

Page-fault Trap

> invalid?

> valid but not available

(16)

Pure Demand Paging

Extreme scenario: Faulting any page request, start executing a process with no pages, only load page when it’s needed, commonly named as pure

demand paging

Hardware: page table and secondary disk

You can save memory usage, but you have to go through page-fault trap mechanism when

you need to start your process

(17)

Outline

Introduction

Virtual Memory Management:

Demand Paging

Copy on Write

Page Replacement
(18)

Copy on Write

Some processes can create child process (i.e. system call called fork() ).

fork() bypasses demand paging mechanism

Many child processes, OS uses shared pages.

Should not copy parent’s pages to reduce memory usage:

copy on write strategy

A copy of shared page is created when a process write a shared page
(19)

Process 1 modifies “copy of page C” not the original “page C”

BEFORE

(20)

Outline

Introduction

Virtual Memory Management:

Demand Paging

Copy on Write

Page Replacement
(21)

Page replacement

Page ~ part/unit of logical memory

Frames ~ part/unit of physical memory

Over-Allocation: a page fault occurs when a process

is executed because all spaces in memory are in use (no free frames).

Over-Allocation sometime occurs because of

multiprogramming (multiple processes access the memory)

We have to get-rid of a ‘victim’ page using page replacement mechanism.
(22)

0-1: OS’ frames 2-7: user’s frames

(23)

Page Replacement Algorithm

1. Find the location of the desired page on the disk 2. Find a free frame:

a. If there’s a free frame, use it.

b. If no free frame, use page replacement

c. Write the victim frame to disk, change the page and frame tables accordingly (valid invalid) 3. Read the desired page into the newly freed frame,

change the page and frame tables 4. Restart the user process

(24)

We want to replace frame with address f

(25)

Outline

Introduction

Virtual Memory Management:

Demand Paging

Copy on Write

Page Replacement
(26)

Thrashing

If a process does not have “enough” pages, the page-fault rate is very high caused by massive page-replacement.

This leads to:

# Low CPU utilization (the process is swapped around rather than executed)

# 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, so that it spends more time for paging than

executing

The effective memory time increases, no work getting done
(27)

3. Multiple page-faults occur

1. CPU utilization low -

add the degree of mulitprogramming 2. A process starts to ask more frames

(28)

Prevent Thrashing

Local Replacement Algorithm: if one process starts thrashing, it cannot steal frames from another process.

The problem hasn’t been solved yet, since thrashing process increases queueing time.

We have to know, how many frames that a

process needs? We observe the locality model of process execution. OS provides a

(29)

Locality

Locality: a set of pages that are actively used together by an executed process

Do not allocate fewer pages than a process’ current

(30)

Locality

Locality model: an executed process moves from locality to locality

A program is generally composed of several different localities that may overlap

Localities are defined by observing the program structure and its data structures

(how the program uses the memory)

(31)

Working-set model

• Δ ≡ working-set window ≡ a fixed number of page references Example: Δ = 10,000 references

WSSi (Working Set Size of Process Pi) =

Total number of pages referenced in the most recent Δ

(varies in time). The size should be carefully estimated, because: ~ if Δ too small will not reach entire locality

~ if Δ too large will overlap several localities ~ if Δ = ∞ will encompass entire program

D = Σ WSSi ≡ total demand for frames

m = total number of available frames

if D > m Thrashing

(32)

Working-set model

Δ = working set window

Working set is an approximation of the program’s locality Keep the locality, even though smaller frames are used in a process

(note that in WS1 we use {1, 2, 5, 6, 7} and in WS2 we use {3, 4})

(33)

Virtual Memory in Linux

(34)

Monitoring Virtual Memory

(DEMO)

http://www.linux.com/news/software/applications/8208-all-about-linux-swap-space http://www.linuxjournal.com/article/8178

References

Related documents

The study was aim to investigate the effects of continuous PCBs exposure on optomotor response (OMR) and retinal photoreceptor cell development-related gene expression in

We use our ob- servations from the visualization to guide further analysis, leading to our findings that nearly 5% of passwords in the RockYou dataset represent pure dates

As regard to this point, we would like to provide some recommendations for the development of future de-radicalization programs that take the onlife character of radicalization

Hardinge Lathes Page 9 Square Shank Tool Holders: Left- & Right-hand Y-Axis.. CW CW1 CH1 T CH L S H

• If the two-stage thermostat changes the call from low heat to high heat, the integrated control module will immediately switch the induced draft blower, gas valve, and

Ivan (2012) in his book “Zero Waste” cited that zero waste management groups will initiate programs that will raise awareness of recycling and environmental

Las características particulares de los eventos secos y húmedos ocurridos en la región de la cuenca hidrográfica de la laguna Sauce Grande, durante el período 1971- 2010, se

Under the assumption of quadratic utility, the optimal sharing rule for the pricing agent yields a multifactor conditional consumption- based capital asset pricing model (CCAPM),