Virtual Memory: Understanding Operating Systems and Memory Management - Prof. Mirela Damia, Study notes of Operating Systems

An in-depth exploration of virtual memory, its management techniques, and solutions to memory management problems. Topics include paging, page table management, and the role of the memory management unit (mmu).

Typology: Study notes

Pre 2010

Uploaded on 02/25/2010

koofers-user-52q
koofers-user-52q ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Page 1
CSC 1600: Operating Systems
Virtual Memory
โ€“2โ€“
Lecture Goals
What is virtual memory?
Virtual memory management
zPaging
Page table management
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Virtual Memory: Understanding Operating Systems and Memory Management - Prof. Mirela Damia and more Study notes Operating Systems in PDF only on Docsity!

CSC 1600: Operating Systems

Virtual Memory

  • 2 โ€“

Lecture Goals

What is virtual memory? Virtual memory management z Paging Page table management

  • 3 โ€“

Storage Hierarchy

Main Memory

  • Cache on Chip (internal cache)
  • External Cache memory
  • RAM

Secondary Storage

  • Hard Disk

Tertiary Storage

โ€ข CD ROM
  • Floppy
  • Tape

Access time decreases

Capacity decreases

Cost increases

  • 4 โ€“

Memory Management Problem 1

How to allocate memory to processes? Partitions are created at load times?

Memory at system start up

OS

Three processes started

OS Process 1^ Process 2^ Process 3

Second processes is finished

OS Process 1^ Process 3

A large fourth process arrives. Process 3 is relocated. How to relocate a process? Expensive.

OS Process 1^ Process 3^ Process 4

  • 7 โ€“

Virtual Memory (VM)

Virtual memory of process on disk

Real memory of system

Map (translate) virtual address to real

  • 8 โ€“

Virtual Memory (VM)

VM is conceptual It is constructed on disk Size of VM is not limited (usually larger than real memory) All process addresses refer to the VM image When the process executes all VM addresses are mapped on to real memory Virtual Memory contents are loaded into the memory on demand

  • 9 โ€“

(Pure) Paging

Virtual and real memory are divided into fixed sized pages Programs are divided into pages A process address (both in virtual & real memory) has two components

Page # Offset within page

  • 10 โ€“

Virtual Memory for a Process

Virtual Address Space Physical Address Space

virtual page number

offset in page

physical page number

offset in page

Translate virtual page number to physical page number

  • 13 โ€“

Paging Idea

When process pages are transferred from VM to real memory, page numbers must be mapped from virtual to real memory addresses This mapping is done by software & hardware When the process is started only the first page (main) is loaded. Other pages are loaded on demand.

  • 14 โ€“

VM โ€“ Memory Management Unit

The position and function of the MMU

  • 15 โ€“

Internal Operation of the MMU

Note that virtual address is 16 bits (64K virtual memory)

But the physical address is 15 bits (32K real memory)

Assume: 64K Virtual Memory 32K Real Memory 4K Page size

  • 16 โ€“

Page Tables

Index of page table is the virtual page #

Page Table (^0) Page frame #

Page protection

Reference bit Modification bit

Validity bit

Page Table Entry

  • 19 โ€“

Address Mapping in Paging (Cont.)

During the execution every page reference is checked against the page map table entry If the validity bit is set (ie., page is in memory) execution continues If the page is not in memory a page fault (interrupt - trap) occurs and the page is fetched into memory If the memory is full, pages are written back using a page replacement algorithm

  • 20 โ€“

Sharing Physical Memory

Process 1Virtual Address Space (^) Physical Address Space

Process 2 Virtual^0 Address Space

OS
V.A.S.
  • 21 โ€“

Process-ID and Page Table Entries

3 4 1

5 2

0 6 2

1

0

Page tables

Physical Memory

PID

  • 22 โ€“

Page Tables in OS Memory...

Process 1 Virtual Address Space

Physical Address Space

Process 2 Virtual^0 Address Space

OS
V.A.S.
  • 25 โ€“

Exercise 2

Consider a logical address space of 1024 pages of 1024 bytes each, mapped onto a physical address space of 512 frames. z What is the format of the virtual address? z What is the format of the physical address? z What is the size of a page table for this process? z Calculate the physical address corresponding to the virtual address 2032 (in decimal)? Use the page table on the right.

โ€ฆ

1 33

1 3

1 14

1 6

Physical address

V