Virtual Memory - Advanced Operating System - Lecture Slides, Slides of Computer Science

These are the lecture Slides of Advanced Operating System which includes Virtual Memory Performance, Resident Set Management, Allocating Pages, Page Fault Frequency Algorithm, Working Set Strategy, Thrashing, Replacement Policy, Multiprogramming Level etc. Key important points are: Virtual Memory, Fragmentation, Dynamic Memory Allocation, Dynamic Memory Challenges, Paged Memory, Program Address Translation, Virtual Address, Paging Advantages, Translation Lookaside Buffer

Typology: Slides

2012/2013

Uploaded on 03/20/2013

dharmaketu
dharmaketu 🇮🇳

4.6

(165)

99 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Virtual Memory
COMP755 1
Virtual Memory
COMP755 Advanced
Operating Systems
Fragmentation
Even the best dynamic memory allocation
scheme causes external fragmentation.
As the amount of RAM in a system
increases, the difficulty in allocating
memory decreases.
As the average size of programs increases
the difficulty in allocating memory
increases.
Moving Programs
with Dynamic Memory Allocation
If memory becomes fragmented, it can be
possible to move programs to reduce
fragmentation.
Programs must be suspended to move
them.
It takes CPU time to move a program in
memory.
F000
100 C200 D300 E400 E500 E600
700 X800
900 Z1000 B1100 B1200 B1300 W1400
1500
F000 C100 D200 E300 E400 E500 X600 Z700 B800 B900 B1000 W1100
1200
1300
1400
1500
Dynamic Memory Challenges
Some memory areas may be allocated for
a long time, possibly fragmenting memory.
Certain programs are hard to move.
Real time programs that may need to run
immediately.
Shared memory requires suspended all
programs using it.
Docsity.com
pf3
pf4
pf5

Partial preview of the text

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

Virtual Memory

COMP755 Advanced Operating Systems

Fragmentation

  • Even the best dynamic memory allocation scheme causes external fragmentation.
  • As the amount of RAM in a system increases, the difficulty in allocating memory decreases.
  • As the average size of programs increases the difficulty in allocating memory increases.

Moving Programs

with Dynamic Memory Allocation

  • If memory becomes fragmented, it can be possible to move programs to reduce fragmentation.
  • Programs must be suspended to move them.
  • It takes CPU time to move a program in memory.

000 F

100

200 C

300 D

400 E

500 E

600 E

700

800 X

900

1000 Z

1100 B

1200 B

1300 B

1400 W

1500

000 F

100 C

200 D

300 E

400 E

500 E

600 X

700 Z

800 B

900 B

1000 B

1100 W

1200

1300

1400

1500

Dynamic Memory Challenges

  • Some memory areas may be allocated for a long time, possibly fragmenting memory.
  • Certain programs are hard to move.
    • Real time programs that may need to run immediately.
    • Shared memory requires suspended all programs using it.

Docsity.com

Paged Memory

  • RAM is divided into fixed sized pages or frames. Pages are usually between ½K and 8K (always a power of 2).
  • Programs are divided into fixed sized pages and stored in the RAM page frames
  • Program pages can be stored anywhere in any order.
  • A page table is used to map program addresses to physical addresses.

Pages in RAM

F

E

D

C

B

A

9

8

7

6

5

4

3

2

1

0

7

C

3

4

1

Page Table

RAM

4

3

2

1

0

Program Address Translation Sizes

  • The length of a virtual address is log 2 (size of addressable memory)
  • The length of the offset portion of the address is the log 2 (size of a page)
  • The page number is all bits left of the offset.
  • The number of page table entries is the programs size / page size.
  • For 32 bit addresses with 4K pages (12 bits) the page number is 20 bits. A 1 MB program will have 256 page table entries.

Example

3 C

4 3AB

1 06E

0 372A

1662C

Physical

Address

Virtual Address

How big is this program?

3 C

4 3AB

1 06E

0 372A

1662C

Physical

Address

Virtual Address

Docsity.com

Combining Paging and

Segmentation

  • An addressing system can use both paging and segmentation.
  • Large segments can be composed of pages.
  • Allows simple memory allocation and logical program division.

Segment Page Offset

Intel Segment Addresses

Segment Page Offset

Segment table Page table

Physical Addr

10 bits 10 bits 12 bits

Sharing Memory

  • Often it is advantageous to share memory.
  • Multiple users running the same program.
  • Programs communicating with shared data
  • The segment tables of different users can point to the same shared memory location.
  • Depending upon the program address used, a user might access private segments or shared segments.

Big Programs

  • Even when using every byte of RAM, it is not always possible to load all the programs users would like.
  • Frequently large parts of programs are never executed. There are many features of Microsoft Word ®^ you have never used.
  • More programs could fit in memory if only the used portions were loaded into RAM.

Locality of Reference

  • Temporal locality - a referenced location is likely to be referenced again.
  • Spatial locality - nearby locations are likely to be referenced soon.

Virtual Memory

  • Unused pages of a program do not need to be in RAM to execute the program.
  • A “resident” bit is added to the page table.
  • Pages not in RAM have the resident bit cleared.
  • Unused pages are stored on disk.
  • When a program references a page with the resident bit clear, the hardware creates a page fault interrupt.

Docsity.com

Virtual Memory OS

  • When a page fault interrupt occurs, the OS reads the desired page from disk into an available page of RAM.
  • The user’s page table is updated to point to the newly loaded page.
  • The program is placed back on the ready list to be executed.

Virtual Memory Advantages

  • Allows you to fit many large programs into a relatively small RAM.
  • Only part of a program needs to be loaded into memory.
  • Eliminates the need to “fit” programs into memory holes.

Virtual Memory Disadvantages

  • Requires complex hardware support.
  • Makes address translation much more complicated.
  • Can reduce performance.
  • Makes program execution time less predictable.

Virtual Memory Performance

  • Computers can retrieve a word from RAM in about 60 ns (6 x 10-8^ sec)
  • A good disk drive can read a block of data in about 6 ms (6 x 10-3^ sec)
  • If the needed page is not in RAM and has to be read from the disk, it takes about 100,000 times longer to get the data.
  • Page fault interrupts have to be kept to a minimum.

Performance Factors

  • The hardware handles the normal address translation.
  • When a page fault occurs, the OS determines where the page will be loaded and what page will be overwritten.
  • The OS must minimize the number of page faults.

Size of the Page

  • Set by the hardware
  • Often between 512 -8K bytes
  • Some system have very large pages, such as 64K or 1MB
  • Bigger the better
  • Should correspond to a size easily written to disk.

Docsity.com