Virtual Memory Paging - PowerPoint PPT Presentation

1 / 48
About This Presentation
Title:

Virtual Memory Paging

Description:

All computers have a limited amount of RAM ... How do you defragment files? ... with a utility called Disk Defragmenter which will reorganise the files stored on disk ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 49
Provided by: stma7
Category:

less

Transcript and Presenter's Notes

Title: Virtual Memory Paging


1
Virtual Memory / Paging
  • Stewart Blakeway
  • FML 208
  • blakews_at_hope.ac.uk
  • 0151 291 3113

2
Session Aims
  • Understand what Paging is
  • Why Paging is used
  • Characteristics and Implications of Paging

3
Available RAM
  • All computers have a limited amount of RAM
  • Typically you can expect 256, 512, 1024 or 2048
    Meg of RAM in your computer
  • This is NOT a lot in comparison to how much
    Memory the Operating System, Applications and
    Devices demand

4
Main Memory
  • Main Memory is essential for Processes to exist
  • This is where instructions reside which are
    interpreted by the CPU

5
Single Process System
Memory
6
Fixed Memory Partition
1000k
Partition 3 400k
600k
Partition 2 300k
300k
Partition 1 200k
100k
7
Variable Memory Partition
1000k
600k
300k
100k
8
Variable Memory Partition
1000k
600k
300k
100k
9
Variable Memory Partition with Compaction
1000k
600k
300k
100k
10
Simple Paging
Process A
Process B
Process C
Memory Space
11
Simple Paging
Process A
Process C
Memory Space
12
Simple Paging
Process A
Process D
Process C
Memory Space
Process E
13
Main Memory
  • In addition to holding instructions RAM is also a
    workspace, a transient storage repository.
  • space must also me made available for
  • Operating System Code
  • Operating System Data
  • User Program Code
  • User Program Data
  • Video Storage Space
  • And so-forth

14
Imagine
  • Loading Microsoft Windows
  • Microsoft Internet Explorer
  • An email Application
  • Microsoft Word
  • And Listening to Music whilst you do all that
    multi-tasking!

It doesnt stop there. You need memory for your
hardware. For example you require memory to
display images on your monitor
15
Memory
  • RAM is very quick, however it is very small.
  • Each time a PROCESS starts it REQUESTS an amount
    of RAM
  • The amount of total RAM requested is far too
    great in comparison to the amount of Physical RAM
    available in Multiprogramming Operating Systems

16
Virtual Memory
  • The Operating System has a Memory Management Unit
    MMU that translates virtual addresses to physical
    addresses in RAM.
  • This is known as Address Translation

17
Swapping
  • When a running program references an address of a
    page which is not resident in RAM, the page has
    to be located in secondary storage and loaded
    into RAM.
  • If RAM is full the resident page has to be
    swapped out to create space for the new page
  • This is know as SWAPPING

18
Swapping
  • Whenever the system requires a component that is
    currently residing in Virtual Memory rather than
    in physical RAM the MMU determines which item or
    items in RAM are not being used at present and
    moves them to the hard disk virtual memory and
    loads the needed component into the just vacated
    physical RAM.

19
Question
  • What is swapped in and out of RAM ?

Answer PAGES
20
Principal Problems to be Handled by the MMU
  • To provide memory space to enable several
    processes to be executed at the same time
  • To provide a satisfactory level of performance
    for the users
  • To protect each process from each other
  • Where desired, to enable sharing of memory space
    between processes
  • To make addressing of memory space as transparent
    as possible for the programmer

21
Question
  • Can several processes be executed at the same
    time?

22
The Operating System
  • Virtual Memory is mapped by the Operating System
    to physical memory
  • This mapping is performed in chunks, called
    pages, which are usually 4K each
  • This mapping is performed with help from the
    hardware -- the CPU has built in support for
    virtual memory to physical memory address
    mappings.

23
Memory Mapping
  • It's this mapping that lets processes run in
    isolated memory spaces, so as to not interfere
    with other processes.
  • This whole scheme was introduced in Intel CPUs
    with Intel 286/386 processors, and it's called
    Protected Mode.

24
Virtual Memory
  • This virtual memory to physical memory address
    mapping lets the operating system pretend that
    there is more memory available than actual
    physical memory in the machine.

25
Question
  • What is Virtual Memory?

Virtual Memory is space on the hard drive that is
mapped out and used to supplement the physical
RAM memory installed in the computer.
26
(No Transcript)
27
Page File
  • The area of the hard disk that stores the RAM
    image is called a page file. It holds pages of
    RAM on the hard disk, and the Operating System
    moves data back and forth between the page file
    and RAM.
  • Previous versions of Windows called this a swap
    file and had a .SWP extension.

28
Key Points about Virtual RAM
  • The key fact to remember about virtual memory is
    that it exists to compensate for the lack of
    physical RAM.  Therefore the relationship between
    them is an inverse one
  • More physical RAM means a reduced need for
    virtual memory
  • Reducing the amount of physical RAM will mean an
    increased need for virtual memory.

29
Thrashing
  • Hard Disks are incredibly slow in comparison to
    RAM
  • When there is a limited amount of RAM, Virtual
    Memory is accessed very frequently and this
    causes Thrashing
  • Thrashing is the Operating System constantly
    swapping PAGES back and forth between RAM and the
    hard disk.
  • Thrashing slows down your computer considerably.

30
Total Size of the Page File
  • The size of the page file is based on how much
    RAM is installed in the computer.
  • By default, Windows XP creates a page file which
    is 1.5 times the amount of installed RAM
  • The page file is placed on the hard drive in the
    same folder as XP

31
Page Faults
  • Only those parts of the program and data that are
    currently in active use need to be held in
    physical RAM. Other parts are then held in a page
    file
  • When a program tries to access some address that
    is not currently in physical RAM, it generates an
    interrupt, called a Page Fault.
  • This asks the system to retrieve the page
    containing the address from the page file
  • This a valid page fault normally happens
    quite invisibly. If there is pressure on space in
    RAM, then parts of code and data that are not
    currently needed can be paged out in order to
    make room

32
Question
  • What is never paged out?

The Kernel remains resident in RAM, This is never
paged out.
33
Invalid Page Faults
  • Sometimes, through program or hardware error, the
    page is not there.
  • The system then has an Invalid Page Fault
    error.
  • This will be a fatal error if detected in a
    program
  • The Application is normally shut down by the
    Operating System

34
Improving Performance
  • The page file is a reserved section of the hard
    drive where data may be written and retrieved as
    needed. Since the paging file and operating
    system files are by default located on the same
    drive, parallel access to both locations is
    impossible. One or the other has to wait, slowing
    down overall system performance. Moving the
    page file to another drive will improve
    performance.

35
Question
  • How else could you improve performance?

Installing more RAM
36
Memory Management in Windows
  • Processes
  • Processes
  • Memory Usage
  • Virtual Memory Usage
  • Performance
  • Commit Charge
  • Physical Memory
  • Kernel Memory

37
Windows Task Manager
Virtual Memory Usage
Process Name
Physical Memory Usage
Each Process has a Virtual Amount of memory Limit
of 4GB
38
Physical Memory
Commit Charge
Kernel Memory
39
Question
  • What is Fragmentation?

The scattering of parts of a file throughout a
disk, eg when the operating system breaks up the
file and fits it into the spaces left vacant by
previously deleted files.
40
Non-Contiguous Page Files
  • Paging files are normally created when a drive is
    relatively empty and finding a large contiguous
    block of space is not a problem.
  • A page file is dynamic by default, it can be
    expanded and contracted depending on the amount
    of extra virtual memory that's needed.
  • If the initial block of drive space that was
    allocated at setup becomes surrounded by
    additional files that have been saved to the
    drive, a split page file can occur when the
    operating system expands it past the initial
    size.

41
Question
  • How do you defragment files?

Windows comes with a utility called Disk
Defragmenter which will reorganise the files
stored on disk
42
Question
  • What creates the Page File?
  • The CPU
  • The RAM
  • The Operating System
  • Its created by magic

43
What is loaded in RAM?
  • The Non-Paged area. Parts of the System which are
    so important that they may never be paged out -
    the area of RAM used for these in XP is called
    the Non-Paged area. This mainly contains core
    code of the system.
  • The Page Pool which can be used to hold
  • Program code,
  • Data pages that have had actual data written to
    them
  • A basic amount of space for the file cache (known
    in Windows 9x systems as Vcache) of files that
    have recently been read from or written to hard
    disk.
  • Any remaining RAM will be used to make the file
    cache larger.

44
Splitting the Memory
  • This Virtual address space is split up into
    chunks, commonly 4K in size, called pages.
  • The physical memory is also split up into chunks,
    also commonly 4K in size, called frames

45
Page Table
  • A page table is the data structure used by a
    virtual memory system in a computer operating
    system to store the mapping between virtual
    addresses and physical addresses
  • The page table is stored in physical RAM

46
Addressing
  • How addressing works will be looked at in future
    Lectures

47
So What do we Know?
  • RAM is Limited
  • Virtual Memory gives the impression that there is
    more RAM than Physical RAM
  • Every Process and Device requires RAM
  • The Kernel is never Paged Out
  • Paging is Managed by the MMU
  • Page Faults are normal interrupts
  • Invalid Page Faults are bad
  • How to view Memory Allocation and Resources in
    Windows

48
Any Questions?
Write a Comment
User Comments (0)
About PowerShow.com