SlideShare a Scribd company logo
Virtual Memory Management
          Background
          Demand Paging
          Copy-on-Write
          Page Replacement
          Allocation of Frames
          Thrashing
1. Background
• Virtual memory – separates user logical memory from physical memory.
   • Only part of the program needs to be in memory for execution
   • Logical address space can be much larger than physical address space




                                         




             Virtual Memory That is Larger Than Physical Memory             2
                              Loganathan R, CSE, HKBKCE
1. Background                      Cntd…


• The virtual address space of a process
  refers to the logical (or virtual) view of how
  a process is stored in memory
• The heap to grow upward in memory as it is
  used for dynamic memory allocation
• The stack to grow downward in memory
  through successive function calls
• The large blank space (or hole) between
  the heap and the stack is part of the virtual
  address space
• Virtual address spaces that include holes
  are known as sparse address spaces



                          Loganathan R, CSE, HKBKCE
                                                         Virtual-address Space
                                                                                 3
1. Background                      Cntd…

• Virtual memory allows files and memory to be shared by two or more
  processes through page sharing
• Benefits:
  • System libraries can be shared by several processes
  • Enables processes to share memory
  • Allow pages to be shared during process creation with the fork() system call




                     Shared Library Using Virtual Memory                      4
                             Loganathan R, CSE, HKBKCE
2. Demand Paging
• Bring a page into memory only
  when it is needed
  –   Less I/O needed
  –   Less memory needed
  –   Faster response
  –   More users
• Page is needed  reference to it
  – invalid reference  abort
  – not-in-memory  bring           to
    memory
• Lazy swapper – never swaps a
  page into memory unless page
  will be needed
  – Swapper that deals with pages is a
    pager
• H/W Support required :
  – Page table valid-invalid bit or
    special value of protection bits
  – Secondary memory holds those                           Transfer of a Paged Memory
      pages that are not present in                          to Contiguous Disk Space
      memory                        Loganathan R, CSE, HKBKCE                      5
2. Demand Paging
Valid-Invalid Bit
• With each page
  table entry a valid–
  invalid       bit     is
  associated
  • v  in-memory
  •i             not-in-
    memory
• Initially valid–invalid
  bit is set to i on all
  entries
• During         address
  translation, if valid–
  invalid bit in page
  table entry is
• i  page fault trap
  to OS               Page Table When Some Pages Are Not in Main Memory
                          Loganathan R, CSE, HKBKCE                6
2. Demand Paging                 Cntd…

Procedure            for
handling the page
fault
1. OS      looks      at
   another table to
   decide:
   – Invalid reference
       abort
   – Just     not     in
      memory
2. Get empty frame
3. Swap page into
   frame
4. Reset tables
5. Set validation bit =
   v
6. Restart          the
   instruction     that
   caused the page                    Steps in Handling a Page Fault
   fault                   Loganathan R, CSE, HKBKCE                   7
2. Demand Paging                                Cntd…
Performance of Demand Paging
• Let p is the probability of a page fault (0  p  1.0)
  if p = 0 no page faults and if p = 1, every reference is a fault
• Effective Access Time EAT = (1 – p) x ma(memory access) + p x page fault time
• Page fault causes
  1. Trap to the operating system
  2. Save the user registers and process state
  3. Determine that the interrupt was a page fault
  4. Check that the page reference was legal and determine the location of the page on
       the disk.
  5. Issue a read from the disk to a free frame:
        Wait in a queue for this device until the read request is serviced.
        Wait for the device seek and /or latency time.
        Begin the transfer of the page to a free frame.
  6.    While waiting, allocate the CPU to some other user (CPU scheduling, optional).
  7.    Receive an interrupt from the disk I/O subsystem (I/O completed).
  8.    Save the registers and process state for the other user (if step 6 is executed).
  9.    Determine that the interrupt was from the disk.
  10.   Correct page table &other tables to show the desired page is now in memory.
  11.   Wait for the CPU to be allocated to this process again.
  12.   Restore the user registers, process state, and new page table, and then resume
        the interrupted instruction.
                                                                              8
                                    Loganathan R, CSE, HKBKCE
2. Demand Paging                       Cntd…

Demand Paging Example
• 3 major components of the page-fault time:
   1. Service the page-fault interrupt.
   2. Read in the page.
   3. Restart the process.
• Memory access time = 200 nanoseconds
• Average page-fault service time = 8 milliseconds
• EAT = (1 – p) x 200 + p (8 milliseconds)
       = (1 – p x 200 + p x 8,000,000
        = 200 + p x 7,999,800
• If one access out of 1,000 causes a page fault, then
                 EAT = 8.2 microseconds.
                 This is a slowdown by a factor of 40!!
• If we want performance degradation to be less than 10 percent, we need
                220 > 200 + 7,999,800 x p,
                20 > 7,999,800 x p,
                p < 0.0000025.

                           Loganathan R, CSE, HKBKCE                       9
3. Copy-on-Write
•   Copy-on-Write (COW) allows both parent and child processes to initially share
    the same pages in memory
          If either process modifies a shared page, only then is the page copied
•   COW allows more efficient process creation as only modified pages are copied
•   Free pages are allocated from a pool of zeroed-out pages
•   Example:
                       Before Process 1 Modifies Page C




                              Loganathan R, CSE, HKBKCE                        10
3. Copy-on-Write                  Cntd…



After Process 1 Modifies Page C




      Loganathan R, CSE, HKBKCE           11
4. Page Replacement
Need For Page Replacement




                                                        12
                            Loganathan R, CSE, HKBKCE
4. Page Replacement                       Cntd…

4.1 Basic Page Replacement
  1. Find the location of the desired page on disk
  2. If there is a free frame, use it otherwise, use a page replacement algorithm to
     select a victim frame, write it to the disk, change the page and frame tables
  3. Bring the desired page into the (newly) free frame; update the page and
     frame tables
  4. Restart the process
• If no frames are free,
  two page transfers
  (one out and one in)
  are required
• To      reduce      this
  overhead by using a
  modify bit or dirty bit
• The modify bit for a
  page is set(must write
  that page to the disk)
  by     the    hardware
  whenever any word or
  byte is written
                                                                               13
                               Loganathan R, CSE, HKBKCE
4. Page Replacement                      Cntd…


If the number of frames available increases, the number of
page faults decreases




        Graph of Page Faults Versus The Number of Frames
                       Loganathan R, CSE, HKBKCE           14
4. Page Replacement                          Cntd…
4.2 First-In-First-Out (FIFO) Algorithm




                                                          There are 15 faults
  • Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
  • 3 frames (3 pages can be in memory at a time per process)
               1   1   4 5
               2   2   1 3 9 page faults
               3   3   2 4
  • 4 frames 1 1 5 4
               2   2   1 5 10 page faults
               3   3   2
               4   4   3
     Belady’s Anomaly: more frames  more page faults in some algoritms
                              Loganathan R, CSE, HKBKCE                         15
4. Page Replacement                        Cntd…


FIFO Illustrating Belady’s Anomaly




       Page-fault curve for FIFO replacement on a reference string
                          Loganathan R, CSE, HKBKCE                  16
4. Page Replacement                          Cntd…

4.3 Optimal Algorithm (OPT or MIN)
• Replace page that will not be used for longest period of time
• Never suffers from Belady's anomaly
• Difficult to implement, because it requires future knowledge of the reference string




  • 4 frames example
                    1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
                             1       4
                             2           6 page faults
                             3
                             4   5
                                  Loganathan R, CSE, HKBKCE                       17
4. Page Replacement                               Cntd…

4.4 Least Recently Used (LRU) page replacement Algorithm
• Replace the page that has not been used for the longest period of time




                                                                  Total 12 faults

 • Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
                                           1     1        1   1   5
                                           2     2        2   2   2
                                           3     5        5   4   4
                                           4     4        3   3   3

                              Loganathan R, CSE, HKBKCE                             18
4. Page Replacement                         Cntd…
LRU page-replacement implementations
1. Using Counter
   – Every page entry associated with time-of-use field and add to the counter /
     clock ; every time page is referenced through this entry, copy the clock into
     the time of use field
   – When a page needs to be changed, look at smallest time value
2. Using Stack
  • Keep a stack of page
     numbers in a double link
     form
  • If page referenced
     move that page to the top
     (requires 6 pointers to be
     changed)
  • No search for replacement
  Both requires H/W support
  S/W implementation through
     interrupt will slow every
     memory reference by a
     factor of at least ten    Loganathan R, CSE, HKBKCE                        19
4. Page Replacement                            Cntd…
4.5 LRU Approximation Page Replacement Algorithms
• Each entry in the page table is associated with the reference bit is set by the
    hardware whenever that page is referenced.
4.5.1 Additional-Reference bit Algorithm
   – Replace the one which is 0 (if one exists)
   – To know the order of use 8-bit shift registers contain the history of page use for
     the last eight time periods(11000100 has been used more recently)
4.5.2 Second chance Algorithm
  – If page to be replaced has reference bit = 1 then:
     • set reference bit 0 and leave page in memory
     • replace next page (in clock order), subject to same rules
 4.5.3 Enhanced Second-Chance Algorithm
• Enhance the second-chance algorithm by considering the reference bit and the
   modify bit as an ordered pair
    1. (0, 0) neither recently used nor modified—best page to replace
    2. (0, 1) not recently used but modified—not quite as good, because the page will
        need to be written out before replacement
    3. (1., 0) recently used but clean—probably will be used again soon
    4. (1,1) recently used and modified—probably will be used again soon, and the
        page will be need to be written out to disk before it can be replaced
                                Loganathan R, CSE, HKBKCE                           20
4. Page Replacement                      Cntd…




Second-Chance (clock) Page-Replacement Algorithm
                Loganathan R, CSE, HKBKCE           21
4. Page Replacement                        Cntd…

4.6 Counting-Based Page Replacement
• Keep a counter of the number of references that have been made to each
   page
• Least frequently Used (LFU) Algorithm: replaces page with smallest
   count, since actively used page should have a large reference count
• Most Frequently Used (MFU) Algorithm: based on the argument that the
   page with the smallest count was probably just brought in and has yet to
   be used
4.7 Page-Buffering Algorithms
• The desired page is read into a free frame from the pool before the victim
   is written out to allow the process to restart as soon as possible and when
   the victim is later written, its frame is added to the free-frame pool.
• Maintain a list of modified pages and whenever the paging device is idle, a
   modified page is written to the disk
• If the frame contents are not modified, it can be reused directly from the
   free-frame pool if it is needed before that frame is reused


                             Loganathan R, CSE, HKBKCE                       22
5. Allocation of Frames
• Each process needs minimum number of pages
• Example: IBM 370 – 6 pages to handle MVC (m/y to m/y)instruction:
   – instruction is 6 bytes, might span 2 pages
• Allocation Algorithms
   – Equal allocation – For example, if there are 100 frames and 5 processes,
      give each process 20 frames.
   – Proportional allocation – Allocate according to the size of process
Let      si  size of process pi                         Example
                                                         m  64
         S   si
                                                         s i  10
         m  total number of frames
                                                         s 2  127
                                 si
         ai  allocation for pi   m                    a1 
                                                               10
                                                                   64  5
                                 S                            137
                                                              127
                                                         a2       64  59
                                                              137
                             Loganathan R, CSE, HKBKCE                     23
5. Allocation of Frames                         Cntd…

5.3 Global versus Local Allocation
• Global replacement allows a process to select a replacement frame
   from the set of all frame i.e. one process can take a frame from
   another
   – A process can select a replacement from its own frames or the frames of any
     lower-priority process
   – Allows a high-priority process to increase its frame allocation
• Local replacement requires that each process select from only its own
  set of allocated frames
   – The number of frames allocated to a process does not change




                             Loganathan R, CSE, HKBKCE                       24
6. Thrashing
Thrashing : high paging activity i.e. a process is spending more time
   paging than executing
6.1 Cause of Thrashing
• If a process does not have enough pages, the page-fault rate is very
   high. This leads to:
   – low CPU utilization So, OS thinks that it needs to increase the degree of
     multiprogramming which leads to more page fault




                            Loganathan R, CSE, HKBKCE                       25
6. Thrashing         Cntd…
Thrashing Prevention
• Why does thrashing occur?
  A locality is a set of pages that are actively used together
   size of locality > total memory size
   – Process migrates from one locality to another
   – Localities may overlap
Working-Set Model
•   working-set window  a fixed number of page references
  Example: 10,000 instruction
• WSSi (Working Set Size of Process Pi) =
  total number of pages referenced in the most recent  (varies
  in time)
   – if  too small will not include entire locality
   – if  too large will include several localities
   – if  =   will include entire program

                                                             26
6. Thrashing                    Cntd…




•   D =  WSSi  total demand frames
•   if D > m  Thrashing
•   Policy if D > m, then suspend one of the processes
•   Approximate the working set with interval timer + a
    reference bit



                      Loganathan R, CSE, HKBKCE           27
6. Thrashing                     Cntd…


Page-Fault Frequency Scheme
• Establish “acceptable” page-fault rate
   – If actual rate too low, process loses frame
   – If actual rate too high, process gains frame




                          Loganathan R, CSE, HKBKCE           28

More Related Content

What's hot

8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
Dr. Loganathan R
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
sangrampatil81
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
Raj Mohan
 
Operating system 37 demand paging
Operating system 37 demand pagingOperating system 37 demand paging
Operating system 37 demand paging
Vaibhav Khanna
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
Kumar Pritam
 
Secondary storage structure-Operating System Concepts
Secondary storage structure-Operating System ConceptsSecondary storage structure-Operating System Concepts
Secondary storage structure-Operating System Concepts
Arjun Kaimattathil
 
Operating system paging and segmentation
Operating system paging and segmentationOperating system paging and segmentation
Operating system paging and segmentation
hamza haseeb
 
Multi processor scheduling
Multi  processor schedulingMulti  processor scheduling
Multi processor scheduling
Shashank Kapoor
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
vampugani
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query Optimization
Ravinder Kamboj
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAnuj Modi
 
Demand paging
Demand pagingDemand paging
Demand paging
SwaroopSorte
 
directory structure and file system mounting
directory structure and file system mountingdirectory structure and file system mounting
directory structure and file system mounting
rajshreemuthiah
 
Memory management
Memory managementMemory management
Memory management
Vishal Singh
 
Raster scan system & random scan system
Raster scan system & random scan systemRaster scan system & random scan system
Raster scan system & random scan system
shalinikarunakaran1
 
Run time storage
Run time storageRun time storage
Run time storage
Rasineni Madhan Mohan Naidu
 
Disk structure
Disk structureDisk structure
Disk structure
Shareb Ismaeel
 
Memory management ppt
Memory management pptMemory management ppt
Memory management ppt
ManishaJha43
 
Advanced computer architechture -Memory Hierarchies and its Properties and Type
Advanced computer architechture -Memory Hierarchies and its Properties and TypeAdvanced computer architechture -Memory Hierarchies and its Properties and Type
Advanced computer architechture -Memory Hierarchies and its Properties and Type
LalfakawmaKh
 

What's hot (20)

8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
 
Operating system 37 demand paging
Operating system 37 demand pagingOperating system 37 demand paging
Operating system 37 demand paging
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Secondary storage structure-Operating System Concepts
Secondary storage structure-Operating System ConceptsSecondary storage structure-Operating System Concepts
Secondary storage structure-Operating System Concepts
 
Operating system paging and segmentation
Operating system paging and segmentationOperating system paging and segmentation
Operating system paging and segmentation
 
Multi processor scheduling
Multi  processor schedulingMulti  processor scheduling
Multi processor scheduling
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query Optimization
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Demand paging
Demand pagingDemand paging
Demand paging
 
directory structure and file system mounting
directory structure and file system mountingdirectory structure and file system mounting
directory structure and file system mounting
 
Memory management
Memory managementMemory management
Memory management
 
Raster scan system & random scan system
Raster scan system & random scan systemRaster scan system & random scan system
Raster scan system & random scan system
 
Run time storage
Run time storageRun time storage
Run time storage
 
Disk structure
Disk structureDisk structure
Disk structure
 
Memory management ppt
Memory management pptMemory management ppt
Memory management ppt
 
Memory management
Memory managementMemory management
Memory management
 
Advanced computer architechture -Memory Hierarchies and its Properties and Type
Advanced computer architechture -Memory Hierarchies and its Properties and TypeAdvanced computer architechture -Memory Hierarchies and its Properties and Type
Advanced computer architechture -Memory Hierarchies and its Properties and Type
 

Viewers also liked

Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managment
Santu Kumar
 
Virtual Memory and Paging
Virtual Memory and PagingVirtual Memory and Paging
Virtual Memory and Paging
Emery Berger
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
Wayne Jones Jnr
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Management
primeteacher32
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory ManagementRajan Kandel
 
Operating System (Scheduling, Input and Output Management, Memory Management,...
Operating System (Scheduling, Input and Output Management, Memory Management,...Operating System (Scheduling, Input and Output Management, Memory Management,...
Operating System (Scheduling, Input and Output Management, Memory Management,...
Project Student
 
3 process management
3 process management3 process management
3 process management
Dr. Loganathan R
 
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
sgpraju
 
Operating System-Memory Management
Operating System-Memory ManagementOperating System-Memory Management
Operating System-Memory Management
Akmal Cikmat
 
Demand Paging-R.D.Sivakumar
Demand Paging-R.D.SivakumarDemand Paging-R.D.Sivakumar
Demand Paging-R.D.Sivakumar
Sivakumar R D .
 
Software quality
Software qualitySoftware quality
Software quality
Santu Kumar
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryMohd Arif
 
Operating Systems - Virtual Memory
Operating Systems - Virtual MemoryOperating Systems - Virtual Memory
Operating Systems - Virtual Memory
Emery Berger
 
Memory Management
Memory ManagementMemory Management
Memory Management
Ramasubbu .P
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
J.T.A.JONES
 
7 Deadlocks
7 Deadlocks7 Deadlocks
7 Deadlocks
Dr. Loganathan R
 

Viewers also liked (20)

Virtual memory ppt
Virtual memory pptVirtual memory ppt
Virtual memory ppt
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managment
 
Virtual Memory and Paging
Virtual Memory and PagingVirtual Memory and Paging
Virtual Memory and Paging
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Management
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
Operating System (Scheduling, Input and Output Management, Memory Management,...
Operating System (Scheduling, Input and Output Management, Memory Management,...Operating System (Scheduling, Input and Output Management, Memory Management,...
Operating System (Scheduling, Input and Output Management, Memory Management,...
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
3 process management
3 process management3 process management
3 process management
 
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
 
Operating System-Memory Management
Operating System-Memory ManagementOperating System-Memory Management
Operating System-Memory Management
 
Demand Paging-R.D.Sivakumar
Demand Paging-R.D.SivakumarDemand Paging-R.D.Sivakumar
Demand Paging-R.D.Sivakumar
 
Software quality
Software qualitySoftware quality
Software quality
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Operating Systems - Virtual Memory
Operating Systems - Virtual MemoryOperating Systems - Virtual Memory
Operating Systems - Virtual Memory
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
VIRTUAL MEMORY
VIRTUAL MEMORYVIRTUAL MEMORY
VIRTUAL MEMORY
 
7 Deadlocks
7 Deadlocks7 Deadlocks
7 Deadlocks
 
4 threads
4 threads4 threads
4 threads
 

Similar to 9 virtual memory management

Virtual Memory.pdf
Virtual Memory.pdfVirtual Memory.pdf
Virtual Memory.pdf
SujanTimalsina5
 
Virtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdfVirtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdf
Harika Pudugosula
 
Segmentation and paging
Segmentation and paging Segmentation and paging
Segmentation and paging
RohanSharma573161
 
Page Replacement
Page ReplacementPage Replacement
Page Replacement
chandinisanz
 
Lect 27 28_29_30_virtual_memory
Lect 27 28_29_30_virtual_memoryLect 27 28_29_30_virtual_memory
Lect 27 28_29_30_virtual_memory
Soumendu Sarkar
 
O ssvv82014
O ssvv82014O ssvv82014
Segmentation with paging methods and techniques
Segmentation with paging methods and techniquesSegmentation with paging methods and techniques
Segmentation with paging methods and techniques
nikhilrana24112003
 
Lecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptxLecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptx
Amanuelmergia
 
Mca ii os u-4 memory management
Mca  ii  os u-4 memory managementMca  ii  os u-4 memory management
Mca ii os u-4 memory management
Rai University
 
CH09.pdf
CH09.pdfCH09.pdf
CH09.pdf
ImranKhan880955
 
Virtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdfVirtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdf
Harika Pudugosula
 
Operating System
Operating SystemOperating System
Operating System
Subhasis Dash
 
Paging and Segmentation
Paging and SegmentationPaging and Segmentation
Paging and Segmentation
sathish sak
 
41 page replacement fifo
41 page replacement fifo41 page replacement fifo
41 page replacement fifomyrajendra
 
Life Of A Dirty Page Inno Db Disk Io
Life Of A Dirty Page Inno Db Disk IoLife Of A Dirty Page Inno Db Disk Io
Life Of A Dirty Page Inno Db Disk Io
Sky Jian
 
4 (1)
4 (1)4 (1)
4 (1)
Mothi R
 

Similar to 9 virtual memory management (20)

Virtual Memory.pdf
Virtual Memory.pdfVirtual Memory.pdf
Virtual Memory.pdf
 
Virtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdfVirtual Memory Management Part - II.pdf
Virtual Memory Management Part - II.pdf
 
Segmentation and paging
Segmentation and paging Segmentation and paging
Segmentation and paging
 
Page Replacement
Page ReplacementPage Replacement
Page Replacement
 
Lect 27 28_29_30_virtual_memory
Lect 27 28_29_30_virtual_memoryLect 27 28_29_30_virtual_memory
Lect 27 28_29_30_virtual_memory
 
O ssvv82014
O ssvv82014O ssvv82014
O ssvv82014
 
Segmentation with paging methods and techniques
Segmentation with paging methods and techniquesSegmentation with paging methods and techniques
Segmentation with paging methods and techniques
 
Lecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptxLecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptx
 
Mca ii os u-4 memory management
Mca  ii  os u-4 memory managementMca  ii  os u-4 memory management
Mca ii os u-4 memory management
 
Os4
Os4Os4
Os4
 
Os4
Os4Os4
Os4
 
CH09.pdf
CH09.pdfCH09.pdf
CH09.pdf
 
Virtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdfVirtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdf
 
Operating System
Operating SystemOperating System
Operating System
 
Paging and Segmentation
Paging and SegmentationPaging and Segmentation
Paging and Segmentation
 
Virtual memory
Virtual memory Virtual memory
Virtual memory
 
CLFS 2010
CLFS 2010CLFS 2010
CLFS 2010
 
41 page replacement fifo
41 page replacement fifo41 page replacement fifo
41 page replacement fifo
 
Life Of A Dirty Page Inno Db Disk Io
Life Of A Dirty Page Inno Db Disk IoLife Of A Dirty Page Inno Db Disk Io
Life Of A Dirty Page Inno Db Disk Io
 
4 (1)
4 (1)4 (1)
4 (1)
 

More from Dr. Loganathan R

Ch 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdfCh 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdf
Dr. Loganathan R
 
IoT Sensing and Actuation.pdf
 IoT Sensing and Actuation.pdf IoT Sensing and Actuation.pdf
IoT Sensing and Actuation.pdf
Dr. Loganathan R
 
Ch 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdfCh 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdf
Dr. Loganathan R
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
Dr. Loganathan R
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
Dr. Loganathan R
 
Introduction to Information Security
Introduction to Information SecurityIntroduction to Information Security
Introduction to Information Security
Dr. Loganathan R
 

More from Dr. Loganathan R (20)

Ch 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdfCh 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdf
 
IoT Sensing and Actuation.pdf
 IoT Sensing and Actuation.pdf IoT Sensing and Actuation.pdf
IoT Sensing and Actuation.pdf
 
Ch 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdfCh 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdf
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
 
Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3
 
Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
 
Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2
 
Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
 
Introduction to Information Security
Introduction to Information SecurityIntroduction to Information Security
Introduction to Information Security
 

Recently uploaded

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 

Recently uploaded (20)

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 

9 virtual memory management

  • 1. Virtual Memory Management  Background  Demand Paging  Copy-on-Write  Page Replacement  Allocation of Frames  Thrashing
  • 2. 1. Background • Virtual memory – separates user logical memory from physical memory. • Only part of the program needs to be in memory for execution • Logical address space can be much larger than physical address space  Virtual Memory That is Larger Than Physical Memory 2 Loganathan R, CSE, HKBKCE
  • 3. 1. Background Cntd… • The virtual address space of a process refers to the logical (or virtual) view of how a process is stored in memory • The heap to grow upward in memory as it is used for dynamic memory allocation • The stack to grow downward in memory through successive function calls • The large blank space (or hole) between the heap and the stack is part of the virtual address space • Virtual address spaces that include holes are known as sparse address spaces Loganathan R, CSE, HKBKCE Virtual-address Space 3
  • 4. 1. Background Cntd… • Virtual memory allows files and memory to be shared by two or more processes through page sharing • Benefits: • System libraries can be shared by several processes • Enables processes to share memory • Allow pages to be shared during process creation with the fork() system call Shared Library Using Virtual Memory 4 Loganathan R, CSE, HKBKCE
  • 5. 2. Demand Paging • Bring a page into memory only when it is needed – Less I/O needed – Less memory needed – Faster response – More users • Page is needed  reference to it – invalid reference  abort – not-in-memory  bring to memory • Lazy swapper – never swaps a page into memory unless page will be needed – Swapper that deals with pages is a pager • H/W Support required : – Page table valid-invalid bit or special value of protection bits – Secondary memory holds those Transfer of a Paged Memory pages that are not present in to Contiguous Disk Space memory Loganathan R, CSE, HKBKCE 5
  • 6. 2. Demand Paging Valid-Invalid Bit • With each page table entry a valid– invalid bit is associated • v  in-memory •i  not-in- memory • Initially valid–invalid bit is set to i on all entries • During address translation, if valid– invalid bit in page table entry is • i  page fault trap to OS Page Table When Some Pages Are Not in Main Memory Loganathan R, CSE, HKBKCE 6
  • 7. 2. Demand Paging Cntd… Procedure for handling the page fault 1. OS looks at another table to decide: – Invalid reference  abort – Just not in memory 2. Get empty frame 3. Swap page into frame 4. Reset tables 5. Set validation bit = v 6. Restart the instruction that caused the page Steps in Handling a Page Fault fault Loganathan R, CSE, HKBKCE 7
  • 8. 2. Demand Paging Cntd… Performance of Demand Paging • Let p is the probability of a page fault (0  p  1.0) if p = 0 no page faults and if p = 1, every reference is a fault • Effective Access Time EAT = (1 – p) x ma(memory access) + p x page fault time • Page fault causes 1. Trap to the operating system 2. Save the user registers and process state 3. Determine that the interrupt was a page fault 4. Check that the page reference was legal and determine the location of the page on the disk. 5. Issue a read from the disk to a free frame: Wait in a queue for this device until the read request is serviced. Wait for the device seek and /or latency time. Begin the transfer of the page to a free frame. 6. While waiting, allocate the CPU to some other user (CPU scheduling, optional). 7. Receive an interrupt from the disk I/O subsystem (I/O completed). 8. Save the registers and process state for the other user (if step 6 is executed). 9. Determine that the interrupt was from the disk. 10. Correct page table &other tables to show the desired page is now in memory. 11. Wait for the CPU to be allocated to this process again. 12. Restore the user registers, process state, and new page table, and then resume the interrupted instruction. 8 Loganathan R, CSE, HKBKCE
  • 9. 2. Demand Paging Cntd… Demand Paging Example • 3 major components of the page-fault time: 1. Service the page-fault interrupt. 2. Read in the page. 3. Restart the process. • Memory access time = 200 nanoseconds • Average page-fault service time = 8 milliseconds • EAT = (1 – p) x 200 + p (8 milliseconds) = (1 – p x 200 + p x 8,000,000 = 200 + p x 7,999,800 • If one access out of 1,000 causes a page fault, then EAT = 8.2 microseconds. This is a slowdown by a factor of 40!! • If we want performance degradation to be less than 10 percent, we need 220 > 200 + 7,999,800 x p, 20 > 7,999,800 x p, p < 0.0000025. Loganathan R, CSE, HKBKCE 9
  • 10. 3. Copy-on-Write • Copy-on-Write (COW) allows both parent and child processes to initially share the same pages in memory If either process modifies a shared page, only then is the page copied • COW allows more efficient process creation as only modified pages are copied • Free pages are allocated from a pool of zeroed-out pages • Example: Before Process 1 Modifies Page C Loganathan R, CSE, HKBKCE 10
  • 11. 3. Copy-on-Write Cntd… After Process 1 Modifies Page C Loganathan R, CSE, HKBKCE 11
  • 12. 4. Page Replacement Need For Page Replacement 12 Loganathan R, CSE, HKBKCE
  • 13. 4. Page Replacement Cntd… 4.1 Basic Page Replacement 1. Find the location of the desired page on disk 2. If there is a free frame, use it otherwise, use a page replacement algorithm to select a victim frame, write it to the disk, change the page and frame tables 3. Bring the desired page into the (newly) free frame; update the page and frame tables 4. Restart the process • If no frames are free, two page transfers (one out and one in) are required • To reduce this overhead by using a modify bit or dirty bit • The modify bit for a page is set(must write that page to the disk) by the hardware whenever any word or byte is written 13 Loganathan R, CSE, HKBKCE
  • 14. 4. Page Replacement Cntd… If the number of frames available increases, the number of page faults decreases Graph of Page Faults Versus The Number of Frames Loganathan R, CSE, HKBKCE 14
  • 15. 4. Page Replacement Cntd… 4.2 First-In-First-Out (FIFO) Algorithm There are 15 faults • Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 • 3 frames (3 pages can be in memory at a time per process) 1 1 4 5 2 2 1 3 9 page faults 3 3 2 4 • 4 frames 1 1 5 4 2 2 1 5 10 page faults 3 3 2 4 4 3 Belady’s Anomaly: more frames  more page faults in some algoritms Loganathan R, CSE, HKBKCE 15
  • 16. 4. Page Replacement Cntd… FIFO Illustrating Belady’s Anomaly Page-fault curve for FIFO replacement on a reference string Loganathan R, CSE, HKBKCE 16
  • 17. 4. Page Replacement Cntd… 4.3 Optimal Algorithm (OPT or MIN) • Replace page that will not be used for longest period of time • Never suffers from Belady's anomaly • Difficult to implement, because it requires future knowledge of the reference string • 4 frames example 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 1 4 2 6 page faults 3 4 5 Loganathan R, CSE, HKBKCE 17
  • 18. 4. Page Replacement Cntd… 4.4 Least Recently Used (LRU) page replacement Algorithm • Replace the page that has not been used for the longest period of time Total 12 faults • Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 1 1 1 1 5 2 2 2 2 2 3 5 5 4 4 4 4 3 3 3 Loganathan R, CSE, HKBKCE 18
  • 19. 4. Page Replacement Cntd… LRU page-replacement implementations 1. Using Counter – Every page entry associated with time-of-use field and add to the counter / clock ; every time page is referenced through this entry, copy the clock into the time of use field – When a page needs to be changed, look at smallest time value 2. Using Stack • Keep a stack of page numbers in a double link form • If page referenced move that page to the top (requires 6 pointers to be changed) • No search for replacement Both requires H/W support S/W implementation through interrupt will slow every memory reference by a factor of at least ten Loganathan R, CSE, HKBKCE 19
  • 20. 4. Page Replacement Cntd… 4.5 LRU Approximation Page Replacement Algorithms • Each entry in the page table is associated with the reference bit is set by the hardware whenever that page is referenced. 4.5.1 Additional-Reference bit Algorithm – Replace the one which is 0 (if one exists) – To know the order of use 8-bit shift registers contain the history of page use for the last eight time periods(11000100 has been used more recently) 4.5.2 Second chance Algorithm – If page to be replaced has reference bit = 1 then: • set reference bit 0 and leave page in memory • replace next page (in clock order), subject to same rules 4.5.3 Enhanced Second-Chance Algorithm • Enhance the second-chance algorithm by considering the reference bit and the modify bit as an ordered pair 1. (0, 0) neither recently used nor modified—best page to replace 2. (0, 1) not recently used but modified—not quite as good, because the page will need to be written out before replacement 3. (1., 0) recently used but clean—probably will be used again soon 4. (1,1) recently used and modified—probably will be used again soon, and the page will be need to be written out to disk before it can be replaced Loganathan R, CSE, HKBKCE 20
  • 21. 4. Page Replacement Cntd… Second-Chance (clock) Page-Replacement Algorithm Loganathan R, CSE, HKBKCE 21
  • 22. 4. Page Replacement Cntd… 4.6 Counting-Based Page Replacement • Keep a counter of the number of references that have been made to each page • Least frequently Used (LFU) Algorithm: replaces page with smallest count, since actively used page should have a large reference count • Most Frequently Used (MFU) Algorithm: based on the argument that the page with the smallest count was probably just brought in and has yet to be used 4.7 Page-Buffering Algorithms • The desired page is read into a free frame from the pool before the victim is written out to allow the process to restart as soon as possible and when the victim is later written, its frame is added to the free-frame pool. • Maintain a list of modified pages and whenever the paging device is idle, a modified page is written to the disk • If the frame contents are not modified, it can be reused directly from the free-frame pool if it is needed before that frame is reused Loganathan R, CSE, HKBKCE 22
  • 23. 5. Allocation of Frames • Each process needs minimum number of pages • Example: IBM 370 – 6 pages to handle MVC (m/y to m/y)instruction: – instruction is 6 bytes, might span 2 pages • Allocation Algorithms – Equal allocation – For example, if there are 100 frames and 5 processes, give each process 20 frames. – Proportional allocation – Allocate according to the size of process Let si  size of process pi Example m  64 S   si s i  10 m  total number of frames s 2  127 si ai  allocation for pi   m a1  10  64  5 S 137 127 a2   64  59 137 Loganathan R, CSE, HKBKCE 23
  • 24. 5. Allocation of Frames Cntd… 5.3 Global versus Local Allocation • Global replacement allows a process to select a replacement frame from the set of all frame i.e. one process can take a frame from another – A process can select a replacement from its own frames or the frames of any lower-priority process – Allows a high-priority process to increase its frame allocation • Local replacement requires that each process select from only its own set of allocated frames – The number of frames allocated to a process does not change Loganathan R, CSE, HKBKCE 24
  • 25. 6. Thrashing Thrashing : high paging activity i.e. a process is spending more time paging than executing 6.1 Cause of Thrashing • If a process does not have enough pages, the page-fault rate is very high. This leads to: – low CPU utilization So, OS thinks that it needs to increase the degree of multiprogramming which leads to more page fault Loganathan R, CSE, HKBKCE 25
  • 26. 6. Thrashing Cntd… Thrashing Prevention • Why does thrashing occur? A locality is a set of pages that are actively used together  size of locality > total memory size – Process migrates from one locality to another – Localities may overlap Working-Set Model •   working-set window  a fixed number of page references Example: 10,000 instruction • WSSi (Working Set Size of Process Pi) = total number of pages referenced in the most recent  (varies in time) – if  too small will not include entire locality – if  too large will include several localities – if  =   will include entire program 26
  • 27. 6. Thrashing Cntd… • D =  WSSi  total demand frames • if D > m  Thrashing • Policy if D > m, then suspend one of the processes • Approximate the working set with interval timer + a reference bit Loganathan R, CSE, HKBKCE 27
  • 28. 6. Thrashing Cntd… Page-Fault Frequency Scheme • Establish “acceptable” page-fault rate – If actual rate too low, process loses frame – If actual rate too high, process gains frame Loganathan R, CSE, HKBKCE 28