SlideShare une entreprise Scribd logo
1  sur  31
9/3/2012   1
Agenda

              Introduction to windows os

              Virtual memory

              Virtual address translation

              Page files / page faults

              Working set

              Physical memory

              Conclusion

9/3/2012                                     2
Introduction to windows os

  Microsoft Windows is a series of graphical interface operating systems
     developed, marketed, and sold by Microsoft.

  Microsoft Windows came to dominate the world's personal computer
     market.

  Microsoft introduced an operating environment named /Windows/ on
     November 20, 1985 as an add-on to MS-DOS in response to the growing
     interest in graphical user interfaces.

  The most recent version of Windows is Windows 7.



9/3/2012                                                                    3
 Windows uses demand paging with Clustering.

  Clustering handles page faults by bringing in not only the
     faulting page but also the multiple pages surrounding the
     faulting page.

  Windows uses clock algorithm.



9/3/2012                                                         4
What is Virtual Memory?

        CPU can address up to 3GB of memory, using its full 32 bits.

        This is normally far more than the RAM of the machine.

        The hardware provides for programs to operate in terms of as

           much as they wish of this full 4GB space as Virtual Memory, those
           parts of the program and data which are currently active being
           loaded into Physical Random Access Memory (RAM).




9/3/2012                                                                       5
Why virtual memory?

  The first is to allow the use of programs that are too big to
     physically fit in memory.

  The other reason is to allow for multitasking – multiple
     programs running at once.




9/3/2012                                                           6
Virtual Memory in Windows
  In Windows the processor manages the mapping in terms of pages of
     4 Kilobytes each a size that has implications for managing virtual
     memory by the system.

  Only some 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 swap file(in as it’s called in Windows
     95/98/ME: Win386.swp )or page file(in Windows NT versions
     including Windows 2000 and XP).




9/3/2012                                                                   7
Address space of Windows

 32-bit Address Space
   32-bits = 2^32 = 4 GB
           3 GB for address space
          1 GB for kernel mode
 64-bit Address space
   64-bits = 2^64 = 17,179,869,184 GB
        x64 today supports 48 bits virtual   = 262,144 GB    = 256 TB
        IA-64 today support 50 bits virtual = 1,048,576 GB   = 1024 TB
        64-bit Windows supports 44 bits      = 16,384 GB     = 16 TB

9/3/2012                                                                  8
Virtual Address Space (V.A.S.)
                                                           00000000
  Process space contains:
                                               User        Unique per
                                             Accessible    process
        The application you are running                   7FFFFFFF
         (.EXE + .DLLs)                                    80000000
        A user-mode stack for each thread   Kernel-mode   System-
                                              accessible   wide
        All static storage defined by the
                                                           FFFFFFFF
         application




9/3/2012                                                             9
Virtual Address Space (V.A.S.)

                                                          00000000
       System space contains:
            Executive, Kernel                User        Unique per
                                            Accessible    process
            Statically-allocated system-
               wide data cells                            7FFFFFFF

              Page tables                                80000000
              Kernel-mode device drivers   Kernel-mode   System-
                                             accessible   wide
              File system cache
                                                          FFFFFFFF
              A kernel-mode stack
               for every thread
               in every
               process



9/3/2012                                                             10
What is loaded in RAM?
 Items of RAM can be divided into two parts :

     -Non paged area

       •   Parts of system which are very important . This cannot

           be paged out.

     -page pool

       •   Program code, Data pages that had actual data written

           to them.


9/3/2012                                                            11
Memory Organization
  Two-level hierarchical memory map

        Page directory table

              Page directory entries (PDEs) point to page table
              One page directory table per process
              Location in page directory register
        Page table

              Page table entries (PTEs) point to page frames
        Page frame

              Contains page of data
  TLB (translation look aside buffer) accelerates address translation

9/3/2012                                                                 12
Virtual Address Translation

  Hardware converts each valid virtual address to a physical
     address


                                           virtual address
                             Virtual page number        Byte within page
             Page
           Directory
                                    Address translation
                                       (hardware) If page                  Page
                                                     not valid             fault
             Page
            Tables
                                  Physical page number Byte within page
               Translation                    physical address
               Lookaside
                 Buffer
9/3/2012                                                                           13
Virtual address translation
                        .




9/3/2012                       14
 Page file
              The page file is a hidden file called pagefile.sys.

              It is regenerated at each boot .

              there is no need to include it in a backup




9/3/2012                                                             15
The paging file and the RAM
  The VMM creates a file on the hard disk that holds the extra memory that
     is needed by the O.S.

  This file is called a paging file (also known as a swap file), and plays an
     important role in virtual memory.

  The paging file combined with the RAM accounts for all of the memory.

  Whenever the O.S. needs a ‘block’ of memory that’s not in the real (RAM)
     memory, the VMM takes a block from the real memory that hasn’t been
     used recently, writes it to the paging file.

  Then it reads the block of memory that the O.S. needs from the paging
     file.


9/3/2012                                                                         16
The paging file and the RAM
  The VMM then takes the block of memory from the paging file, and
     moves it into the real memory – in place of the old block.

  This process is called swapping (also known as paging),

  The blocks of memory that are swapped are called pages.




9/3/2012                                                              17
Page fault

  When the program needs the page which is not in main
     memory the page fault interrupt will be invoked.

  If the this is available on disk then it will be swapped.

  If it is not available due to some hardware problems the
     system will have ‘invalid page fault error’.

  It may manifest itself as a ‘blue screen’ failure with a STOP
     code.

9/3/2012                                                           18
Page Faults
  A page fault occurs when there is a reference to a page that isn’t
     mapped to a physical page

  The system goes to the appropriate block in the associated file to find
     the contents of the page:

        Physical page is allocated

        Block is read into physical page

        Page table entry is filled in

        Exception is dismissed

        Processor re-executes the instruction that caused the page fault

  The page has now been “faulted into” the process “working set”

  Pages are only brought into memory as a result of page faults
9/3/2012                                                                     19
Disadvantages of virtual memory

  Virtual memory can slow down performance.

  If the size of virtual memory is quite large in comparison to the real
     memory, then more swapping to and from the hard disk will occur as a
     result.

  Accessing the hard disk is far slower than using system memory.

  Using too many programs at once in a system with an insufficient
     amount of RAM results in constant disk swapping – also
     called thrashing.


9/3/2012                                                                    20
Working Set List


                        newer pages                        older pages



                                         Working Set


 All the physical pages “owned” by a process

    E.g. the pages the process can reference without incurring a page fault

 A process always starts with an empty working set

    It then incurs page faults when referencing a page that isn’t in its

      working set

    Many page faults may be resolved from memory
Working Set

 Each process has a default working set minimum and maximum

    Can change with SetProcessWorkingSet

    Working set minimum controls maximum number of locked

     pages (VirtualLock)

    Minimum is also reserved from RAM as a guarantee to the

     process

    Working set maximum is ignored

 If there’s ample memory, process working set represents all the
  memory it has referenced (but not freed)
Working Set Replacement

                                                                 To standby
                                                                or modified
                                                                   page list


                               Working Set

 When memory manager decides the process is large enough, it
  give up pages to make room for new pages
 Local page replacement policy
    Means that a single process cannot take over all of physical
     memory unless other processes aren’t using it
    Page replacement algorithm is least recently accessed
     (pages are aged when available memory is low)
Working Set Breakdown

 Consists of 2 types of pages:

    Shareable (of which some may be shared)

    Private

 Four performance counters available:

    Working Set Shareable

         Working Set Shared (subset of shareable that are currently shared)

    Working Set Private

    Working Set Size (total of WS Shareable+Private)

         Note: adding this up for each process overcounts shared pages
Managing Physical Memory

 System keeps unassigned physical pages on one of several lists

    Free page list

    Modified page list

    Standby page lists (8 as of Vista & later)

    Zero page list

    Bad page list - pages that failed memory test at system startup

 Lists are implemented by entries in the “PFN database”

    Maintained as FIFO lists or queues
Standby and Modified Page Lists

 Modified pages go to modified (dirty) list

    Avoids writing pages back to disk too soon

 Unmodified pages go to standby (clean) lists

 They form a system-wide cache of “pages likely to be needed again”

    Pages can be faulted back into a process from the standby and

     modified page list

    These are counted as page faults, but not page reads
Modified Page Writer

 When modified list reaches certain size, modified page writer system

  thread is awoken to write pages out

    Also triggered when memory is overcommitted (too few free pages)

    Does not flush entire modified page list

 Pages move from the modified list to the standby list

    E.g. can still be soft faulted into a working set
Free and Zero Page Lists
 Free Page List

    Used for page reads

    Private modified pages go here on process exit

    Pages contain junk in them (e.g. not zeroed)

    On most busy systems, this is empty

 Zero Page List

    Used to satisfy demand zero page faults

         References to private pages that have not been created yet
    When free page list has 8 or more pages, a priority zero thread is awoken
      to zero them
    On most busy systems, this is empty too
Super Fetch
 Superfetch proactively repopulates RAM with the most useful data

    Sets priority of pages to optimal value, based on the page history and

     other analysis that it performs

    Takes into account frequency of page usage, usage of page in context

     of other pages in memory

 Scenarios SuperFetch improves include

    Resume from hibernate and suspend

    Fast user switching

    Performance after infrequent or low priority tasks execute

    Application launch
Conclusion



9/3/2012                30
Thank you



9/3/2012               31

Contenu connexe

Tendances

Structure of operating system
Structure of operating systemStructure of operating system
Structure of operating system
Rafi Dar
 
Secondary storage management in os
Secondary storage management in osSecondary storage management in os
Secondary storage management in os
Sumant Diwakar
 
Ram and-rom-chips
Ram and-rom-chipsRam and-rom-chips
Ram and-rom-chips
Anuj Modi
 

Tendances (20)

Synchronization in distributed systems
Synchronization in distributed systems Synchronization in distributed systems
Synchronization in distributed systems
 
Structure of operating system
Structure of operating systemStructure of operating system
Structure of operating system
 
Multiprocessor architecture
Multiprocessor architectureMultiprocessor architecture
Multiprocessor architecture
 
file sharing semantics by Umar Danjuma Maiwada
file sharing semantics by Umar Danjuma Maiwada file sharing semantics by Umar Danjuma Maiwada
file sharing semantics by Umar Danjuma Maiwada
 
File system Os
File system OsFile system Os
File system Os
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 
Secondary storage management in os
Secondary storage management in osSecondary storage management in os
Secondary storage management in os
 
distributed Computing system model
distributed Computing system modeldistributed Computing system model
distributed Computing system model
 
Windows kernel
Windows kernelWindows kernel
Windows kernel
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systems
 
Ram and-rom-chips
Ram and-rom-chipsRam and-rom-chips
Ram and-rom-chips
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Distributed file system
Distributed file systemDistributed file system
Distributed file system
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
File replication
File replicationFile replication
File replication
 
Windows Architecture
Windows ArchitectureWindows Architecture
Windows Architecture
 
Operating Systems - memory management
Operating Systems - memory managementOperating Systems - memory management
Operating Systems - memory management
 
Distributed operating system(os)
Distributed operating system(os)Distributed operating system(os)
Distributed operating system(os)
 
Memory management
Memory managementMemory management
Memory management
 

En vedette (7)

Os security issues
Os security issuesOs security issues
Os security issues
 
cmd commands
cmd commandscmd commands
cmd commands
 
I.T ACT 2000
I.T ACT 2000 I.T ACT 2000
I.T ACT 2000
 
Cybercrime
CybercrimeCybercrime
Cybercrime
 
Memory management
Memory managementMemory management
Memory management
 
Operating System-Memory Management
Operating System-Memory ManagementOperating System-Memory Management
Operating System-Memory Management
 
Memory management
Memory managementMemory management
Memory management
 

Similaire à Windows memory management

State of the Art Thin Provisioning
State of the Art Thin ProvisioningState of the Art Thin Provisioning
State of the Art Thin Provisioning
Stephen Foskett
 
Chapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.pptChapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.ppt
MonirJihad1
 
Os solaris memory management
Os  solaris memory managementOs  solaris memory management
Os solaris memory management
Tech_MX
 

Similaire à Windows memory management (20)

virtual memory - Computer operating system
virtual memory - Computer operating systemvirtual memory - Computer operating system
virtual memory - Computer operating system
 
State of the Art Thin Provisioning
State of the Art Thin ProvisioningState of the Art Thin Provisioning
State of the Art Thin Provisioning
 
ppt
pptppt
ppt
 
Linux Memory
Linux MemoryLinux Memory
Linux Memory
 
I/O System and Case study
I/O System and Case studyI/O System and Case study
I/O System and Case study
 
NOV11 virtual memory.ppt
NOV11 virtual memory.pptNOV11 virtual memory.ppt
NOV11 virtual memory.ppt
 
Chapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.pptChapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.ppt
 
Nachos 2
Nachos 2Nachos 2
Nachos 2
 
Abhaycavirtual memory and the pagehit.pptx
Abhaycavirtual memory and the pagehit.pptxAbhaycavirtual memory and the pagehit.pptx
Abhaycavirtual memory and the pagehit.pptx
 
NOV11 virtual memory.ppt
NOV11 virtual memory.pptNOV11 virtual memory.ppt
NOV11 virtual memory.ppt
 
Os solaris memory management
Os  solaris memory managementOs  solaris memory management
Os solaris memory management
 
virtual memory
virtual memoryvirtual memory
virtual memory
 
I/O System and Case Study
I/O System and Case StudyI/O System and Case Study
I/O System and Case Study
 
Power Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.pptPower Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.ppt
 
Windows
WindowsWindows
Windows
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
virtual memory.ppt
virtual memory.pptvirtual memory.ppt
virtual memory.ppt
 
Hadoop Distributed File System for Big Data Analytics
Hadoop Distributed File System for Big Data AnalyticsHadoop Distributed File System for Big Data Analytics
Hadoop Distributed File System for Big Data Analytics
 
I/O System and Case study
I/O System and Case studyI/O System and Case study
I/O System and Case study
 
os
osos
os
 

Plus de Tech_MX

Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
Tech_MX
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 
String & its application
String & its applicationString & its application
String & its application
Tech_MX
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2
Tech_MX
 
Stack data structure
Stack data structureStack data structure
Stack data structure
Tech_MX
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
Tech_MX
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
Tech_MX
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2
Tech_MX
 
Set data structure
Set data structure Set data structure
Set data structure
Tech_MX
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
Tech_MX
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
Tech_MX
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pc
Tech_MX
 
More on Lex
More on LexMore on Lex
More on Lex
Tech_MX
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbms
Tech_MX
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
Tech_MX
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
Tech_MX
 

Plus de Tech_MX (20)

Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Uid
UidUid
Uid
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
String & its application
String & its applicationString & its application
String & its application
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
 
Spss
SpssSpss
Spss
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2
 
Set data structure
Set data structure Set data structure
Set data structure
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 
Parsing
ParsingParsing
Parsing
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pc
 
More on Lex
More on LexMore on Lex
More on Lex
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbms
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
 

Dernier

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Dernier (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

Windows memory management

  • 2. Agenda  Introduction to windows os  Virtual memory  Virtual address translation  Page files / page faults  Working set  Physical memory  Conclusion 9/3/2012 2
  • 3. Introduction to windows os  Microsoft Windows is a series of graphical interface operating systems developed, marketed, and sold by Microsoft.  Microsoft Windows came to dominate the world's personal computer market.  Microsoft introduced an operating environment named /Windows/ on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces.  The most recent version of Windows is Windows 7. 9/3/2012 3
  • 4.  Windows uses demand paging with Clustering.  Clustering handles page faults by bringing in not only the faulting page but also the multiple pages surrounding the faulting page.  Windows uses clock algorithm. 9/3/2012 4
  • 5. What is Virtual Memory?  CPU can address up to 3GB of memory, using its full 32 bits.  This is normally far more than the RAM of the machine.  The hardware provides for programs to operate in terms of as much as they wish of this full 4GB space as Virtual Memory, those parts of the program and data which are currently active being loaded into Physical Random Access Memory (RAM). 9/3/2012 5
  • 6. Why virtual memory?  The first is to allow the use of programs that are too big to physically fit in memory.  The other reason is to allow for multitasking – multiple programs running at once. 9/3/2012 6
  • 7. Virtual Memory in Windows  In Windows the processor manages the mapping in terms of pages of 4 Kilobytes each a size that has implications for managing virtual memory by the system.  Only some 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 swap file(in as it’s called in Windows 95/98/ME: Win386.swp )or page file(in Windows NT versions including Windows 2000 and XP). 9/3/2012 7
  • 8. Address space of Windows 32-bit Address Space 32-bits = 2^32 = 4 GB  3 GB for address space  1 GB for kernel mode 64-bit Address space 64-bits = 2^64 = 17,179,869,184 GB  x64 today supports 48 bits virtual = 262,144 GB = 256 TB  IA-64 today support 50 bits virtual = 1,048,576 GB = 1024 TB  64-bit Windows supports 44 bits = 16,384 GB = 16 TB 9/3/2012 8
  • 9. Virtual Address Space (V.A.S.) 00000000  Process space contains: User Unique per Accessible process  The application you are running 7FFFFFFF (.EXE + .DLLs) 80000000  A user-mode stack for each thread Kernel-mode System- accessible wide  All static storage defined by the FFFFFFFF application 9/3/2012 9
  • 10. Virtual Address Space (V.A.S.) 00000000  System space contains:  Executive, Kernel User Unique per Accessible process  Statically-allocated system- wide data cells 7FFFFFFF  Page tables 80000000  Kernel-mode device drivers Kernel-mode System- accessible wide  File system cache FFFFFFFF  A kernel-mode stack for every thread in every process 9/3/2012 10
  • 11. What is loaded in RAM? Items of RAM can be divided into two parts : -Non paged area • Parts of system which are very important . This cannot be paged out. -page pool • Program code, Data pages that had actual data written to them. 9/3/2012 11
  • 12. Memory Organization  Two-level hierarchical memory map  Page directory table  Page directory entries (PDEs) point to page table  One page directory table per process  Location in page directory register  Page table  Page table entries (PTEs) point to page frames  Page frame  Contains page of data  TLB (translation look aside buffer) accelerates address translation 9/3/2012 12
  • 13. Virtual Address Translation  Hardware converts each valid virtual address to a physical address virtual address Virtual page number Byte within page Page Directory Address translation (hardware) If page Page not valid fault Page Tables Physical page number Byte within page Translation physical address Lookaside Buffer 9/3/2012 13
  • 15.  Page file  The page file is a hidden file called pagefile.sys.  It is regenerated at each boot .  there is no need to include it in a backup 9/3/2012 15
  • 16. The paging file and the RAM  The VMM creates a file on the hard disk that holds the extra memory that is needed by the O.S.  This file is called a paging file (also known as a swap file), and plays an important role in virtual memory.  The paging file combined with the RAM accounts for all of the memory.  Whenever the O.S. needs a ‘block’ of memory that’s not in the real (RAM) memory, the VMM takes a block from the real memory that hasn’t been used recently, writes it to the paging file.  Then it reads the block of memory that the O.S. needs from the paging file. 9/3/2012 16
  • 17. The paging file and the RAM  The VMM then takes the block of memory from the paging file, and moves it into the real memory – in place of the old block.  This process is called swapping (also known as paging),  The blocks of memory that are swapped are called pages. 9/3/2012 17
  • 18. Page fault  When the program needs the page which is not in main memory the page fault interrupt will be invoked.  If the this is available on disk then it will be swapped.  If it is not available due to some hardware problems the system will have ‘invalid page fault error’.  It may manifest itself as a ‘blue screen’ failure with a STOP code. 9/3/2012 18
  • 19. Page Faults  A page fault occurs when there is a reference to a page that isn’t mapped to a physical page  The system goes to the appropriate block in the associated file to find the contents of the page:  Physical page is allocated  Block is read into physical page  Page table entry is filled in  Exception is dismissed  Processor re-executes the instruction that caused the page fault  The page has now been “faulted into” the process “working set”  Pages are only brought into memory as a result of page faults 9/3/2012 19
  • 20. Disadvantages of virtual memory  Virtual memory can slow down performance.  If the size of virtual memory is quite large in comparison to the real memory, then more swapping to and from the hard disk will occur as a result.  Accessing the hard disk is far slower than using system memory.  Using too many programs at once in a system with an insufficient amount of RAM results in constant disk swapping – also called thrashing. 9/3/2012 20
  • 21. Working Set List newer pages older pages Working Set  All the physical pages “owned” by a process  E.g. the pages the process can reference without incurring a page fault  A process always starts with an empty working set  It then incurs page faults when referencing a page that isn’t in its working set  Many page faults may be resolved from memory
  • 22. Working Set  Each process has a default working set minimum and maximum  Can change with SetProcessWorkingSet  Working set minimum controls maximum number of locked pages (VirtualLock)  Minimum is also reserved from RAM as a guarantee to the process  Working set maximum is ignored  If there’s ample memory, process working set represents all the memory it has referenced (but not freed)
  • 23. Working Set Replacement To standby or modified page list Working Set  When memory manager decides the process is large enough, it give up pages to make room for new pages  Local page replacement policy  Means that a single process cannot take over all of physical memory unless other processes aren’t using it  Page replacement algorithm is least recently accessed (pages are aged when available memory is low)
  • 24. Working Set Breakdown  Consists of 2 types of pages:  Shareable (of which some may be shared)  Private  Four performance counters available:  Working Set Shareable  Working Set Shared (subset of shareable that are currently shared)  Working Set Private  Working Set Size (total of WS Shareable+Private)  Note: adding this up for each process overcounts shared pages
  • 25. Managing Physical Memory  System keeps unassigned physical pages on one of several lists  Free page list  Modified page list  Standby page lists (8 as of Vista & later)  Zero page list  Bad page list - pages that failed memory test at system startup  Lists are implemented by entries in the “PFN database”  Maintained as FIFO lists or queues
  • 26. Standby and Modified Page Lists  Modified pages go to modified (dirty) list  Avoids writing pages back to disk too soon  Unmodified pages go to standby (clean) lists  They form a system-wide cache of “pages likely to be needed again”  Pages can be faulted back into a process from the standby and modified page list  These are counted as page faults, but not page reads
  • 27. Modified Page Writer  When modified list reaches certain size, modified page writer system thread is awoken to write pages out  Also triggered when memory is overcommitted (too few free pages)  Does not flush entire modified page list  Pages move from the modified list to the standby list  E.g. can still be soft faulted into a working set
  • 28. Free and Zero Page Lists  Free Page List  Used for page reads  Private modified pages go here on process exit  Pages contain junk in them (e.g. not zeroed)  On most busy systems, this is empty  Zero Page List  Used to satisfy demand zero page faults  References to private pages that have not been created yet  When free page list has 8 or more pages, a priority zero thread is awoken to zero them  On most busy systems, this is empty too
  • 29. Super Fetch  Superfetch proactively repopulates RAM with the most useful data  Sets priority of pages to optimal value, based on the page history and other analysis that it performs  Takes into account frequency of page usage, usage of page in context of other pages in memory  Scenarios SuperFetch improves include  Resume from hibernate and suspend  Fast user switching  Performance after infrequent or low priority tasks execute  Application launch