SlideShare a Scribd company logo
Storage Management

• Page replacement- FIFO




                           1
Recap


In the last class, you have learnt

    Demand Paging
    Steps to handle page faults




                                     2
HOME     PREVIOUS TOPIC NEXT
PREVIOUS QUESTION PAPERS FOR OS
CPP TUTORIALS




                                  3
Objective


  On completion of this class, you will be able to

  know
• Concepts of Page Replacement

• FIFO page replacement algorithm




                                                     4
Page Replacement

• When a user process is executing, a page fault
  occurs
• The OS determines where the desired page is
  residing on the disk
• Finds that there are no free frames on the free-
  frame list
• All memory is in use Figure:1

                                                     5
Need For Page Replacement




         Figure: 1
                            6
Procedure to find free Frame:

• Page replacement – find some page in memory,
 which is not really in use & swap it out
  – In order to swap use one of the Page replacement
    algorithm
  – Select an algorithm which will result in minimum number
    of page faults & improves the performance

• Same page may be brought into memory several
 times
                                                          7
Basic Page Replacement

•       Find the location of the desired page on disk
•       Find a free frame:
    •    If there is a free frame, use it
    •    If there is no free frame, use a page replacement
         algorithm to select a victim frame
•       Read the desired page into the (newly) free
        frame as shown in Fig: 2
•       Update the page and frame tables
•       Restart the process
                                                             8
Page Replacement




      Fig: 2
                   9
Page Replacement
• Prevent over-allocation of memory
• Include page replacement
• Use modify (dirty) bit to reduce overhead of
  page transfers
• Each page or a frame may have a modify bit
  associated with it in the hardware



                                                 10
Page Replacement
• Modify bit for a page is set by the hardware when a
  word or byte is written to page
• Only modified pages are written to disk
• Page replacement completes separation between
  logical memory and physical memory
• Large virtual memory can be provided on a smaller
  physical memory


                                                 11
Page Replacement Algorithm

 How to select the page replacement
  algorithm?
• The string of memory references is called
  reference string
• Evaluate the algorithm by running on a
  reference string and compute the number of
  page faults
• Select the one with lowest page-fault rate
                                               12
Page Replacement Algorithm

How to determine the no. of page faults?

• Need to have the knowledge of number of

  page frames available for a reference string

• As number of page frames increases the

  page faults will decrease


                                                 13
FIFO Replacement Algorithms

FIFO - First In First Out
• Simplest page replacement algorithm
• Replace the page that has been in primary
  memory the longest
• FIFO queue holds the pages in memory
• Replace the page at the head of the queue
• The new page is inserted at the tail of the queue
                                                  14
FIFO Page Replacement
• Page fault’s at 7,0,1,2,3,0,4,2,3,0,1,2,7,0,1 of
  reference string




                          Fig 3
                                                     15
FIFO

Example : 12
references, 9
faults




                       Fig 4   16
41 page replacement fifo
FIFO

 Disadvantages of FIFO algorithm
 Performance is not always good
 The page in active use is replaced for the new one
 This bad replacement choice increases the page
  faults
 To illustrate the problem consider the
 Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

                                                         18
FIFO
   3 frames (3 pages can be in memory at
    a time per process)
                1   1    4 55
                         4
                2   2    1 33
                         1        9 page faults
                3   3    2 44
                         2

                        Fig 5
       4 frames

        1   1   5 44
                5
        2   2   1 55
                1        10 page faults
        3   3   2
                2

        4   4   3
                3

            Fig 6                                 19
Belady's Anomaly
• FIFO with 3 page frames Fig : 7 (a)
• FIFO with 4 page frames Fig : 7 (b)
• P's show which page references show page
  faults



                 Fig 7




                 Fig 7
                                             20
FIFO

 The result is unexpected and is known as

  Belady’s Anomaly

 For some page replacement algorithm

  Page-fault rate may increase as the no. of

  allocated frames increase


                                               21
Paging Behavior with Increasing
   Number of Page Frames




               Fig 8

                                  22
FIFO Illustrating Belady’s Anomaly




                 Fig 9
                                     23
Summary

 In this class, you have learnt
       Concepts of Page replacement
       FIFO algorithm




                                       24
Frequently Asked Questions

What is the need for page replacement?

How do you find a free frame?

What is dirty bit?

What is meant by page replacement?

Explain FIFO page replacement algorithm

                                          25
Quiz
1. Use _____________to reduce overhead of page
  transfers
 a) Segmentation
 b) Modify (dirty) bit
 c) None

2. Modify bit for a page is _____by the hardware when a
  word or byte is written to page
   a) Reset
   b) Hole
   c) set
   d) None
                                                          26
Quiz
3. ___________completes separation between logical
   memory and physical memory
a) Page number
b) MULTICS
c) Page replacement
d) None
4. Each page or a frame may have a
   ___________associated with it in the hardware
a) External fragmentation
b) modify bit
c) Compaction
d) None
                                                     27
Quiz

5. What is a Page?
a) Blocks of logical memory
b) Blocks of physical memory
c) Blocks of virtual memory
d) None

6. FIFO queue replaces the pages at
a) Head of queue
b) Tail of queue
c) Both
d) None
                                      28
Quiz
7. ___________completes separation between logical
   memory and physical memory
a) Page number
b) MULTICS
c) Page replacement
d) None
8. Each page or a frame may have a ___________associated
    with it in the hardware
a) External fragmentation
b) modify bit
c) Compaction
d) None
                                                     29
Other subject materials

•   Web designing
•   Micro processors
•   C++ tutorials
•   java

home

More Related Content

PDF
7 Deadlocks
PPTX
Page replacement algorithms
PPTX
OS concepts 6 OS for various computing environments
PPT
Memory management
PPTX
Operating system memory management
PPTX
Memory Management in OS
PPTX
Virtual Memory in Operating System
PPT
Classical problem of synchronization
7 Deadlocks
Page replacement algorithms
OS concepts 6 OS for various computing environments
Memory management
Operating system memory management
Memory Management in OS
Virtual Memory in Operating System
Classical problem of synchronization

What's hot (20)

PPTX
Page replacement algorithms
PPTX
Computer architecture page replacement algorithms
PPTX
Segmentation in Operating Systems.
PPTX
Allocation of Frames & Thrashing
PDF
Resource management
PPTX
Operating system paging and segmentation
PPT
cache memory
PPT
Parallel processing
PDF
OS - Process Concepts
PPTX
Hardware Multi-Threading
PPTX
Process synchronization in Operating Systems
PPTX
Demand paging
PPT
File models and file accessing models
PPTX
Process synchronization
PPTX
Semophores and it's types
PPT
Shared memory
PPTX
Computer architecture virtual memory
PPTX
Multithreading models.ppt
PPTX
Auxiliary Memory in computer Architecture.pptx
PPTX
Disk Scheduling Algorithm in Operating System
Page replacement algorithms
Computer architecture page replacement algorithms
Segmentation in Operating Systems.
Allocation of Frames & Thrashing
Resource management
Operating system paging and segmentation
cache memory
Parallel processing
OS - Process Concepts
Hardware Multi-Threading
Process synchronization in Operating Systems
Demand paging
File models and file accessing models
Process synchronization
Semophores and it's types
Shared memory
Computer architecture virtual memory
Multithreading models.ppt
Auxiliary Memory in computer Architecture.pptx
Disk Scheduling Algorithm in Operating System
Ad

Similar to 41 page replacement fifo (20)

PPT
40 demand paging
PPT
Page Replacement
PDF
Virtual Memory Management Part - II.pdf
PDF
9 virtual memory management
PPT
Operating System
PDF
Virtual Memory.pdf
PPTX
3_page_replacement_algorithms computer system and architecture
PPTX
Lecture 8- Virtual Memory Final.pptx
PPT
Pagereplacement algorithm(computional concept)
PPTX
virtual memory Operating system
PPT
Segmentation and paging
PPTX
CHAPTER 2 - Operating systems Virtual Memory.pptx
PPTX
operating system virtual memory and logical memory
PDF
Unit 5
PPT
42 lru optimal
PDF
381 ccs chapter7_updated(1)
DOCX
Module4
PPT
Virtual memory
PDF
Virtual memory
PPTX
Lect 27 28_29_30_virtual_memory
40 demand paging
Page Replacement
Virtual Memory Management Part - II.pdf
9 virtual memory management
Operating System
Virtual Memory.pdf
3_page_replacement_algorithms computer system and architecture
Lecture 8- Virtual Memory Final.pptx
Pagereplacement algorithm(computional concept)
virtual memory Operating system
Segmentation and paging
CHAPTER 2 - Operating systems Virtual Memory.pptx
operating system virtual memory and logical memory
Unit 5
42 lru optimal
381 ccs chapter7_updated(1)
Module4
Virtual memory
Virtual memory
Lect 27 28_29_30_virtual_memory
Ad

More from myrajendra (20)

PPT
Fundamentals
PPT
Data type
PPTX
Hibernate example1
PPTX
Jdbc workflow
PPTX
2 jdbc drivers
PPTX
3 jdbc api
PPTX
4 jdbc step1
PPTX
Dao example
PPTX
Sessionex1
PPTX
Internal
PPTX
3. elements
PPTX
2. attributes
PPTX
1 introduction to html
PPTX
Headings
PPTX
Forms
PPT
PPTX
Views
PPTX
Views
PPTX
Views
PPT
Starting jdbc
Fundamentals
Data type
Hibernate example1
Jdbc workflow
2 jdbc drivers
3 jdbc api
4 jdbc step1
Dao example
Sessionex1
Internal
3. elements
2. attributes
1 introduction to html
Headings
Forms
Views
Views
Views
Starting jdbc

41 page replacement fifo

  • 1. Storage Management • Page replacement- FIFO 1
  • 2. Recap In the last class, you have learnt Demand Paging Steps to handle page faults 2
  • 3. HOME PREVIOUS TOPIC NEXT PREVIOUS QUESTION PAPERS FOR OS CPP TUTORIALS 3
  • 4. Objective On completion of this class, you will be able to know • Concepts of Page Replacement • FIFO page replacement algorithm 4
  • 5. Page Replacement • When a user process is executing, a page fault occurs • The OS determines where the desired page is residing on the disk • Finds that there are no free frames on the free- frame list • All memory is in use Figure:1 5
  • 6. Need For Page Replacement Figure: 1 6
  • 7. Procedure to find free Frame: • Page replacement – find some page in memory, which is not really in use & swap it out – In order to swap use one of the Page replacement algorithm – Select an algorithm which will result in minimum number of page faults & improves the performance • Same page may be brought into memory several times 7
  • 8. Basic Page Replacement • Find the location of the desired page on disk • Find a free frame: • If there is a free frame, use it • If there is no free frame, use a page replacement algorithm to select a victim frame • Read the desired page into the (newly) free frame as shown in Fig: 2 • Update the page and frame tables • Restart the process 8
  • 9. Page Replacement Fig: 2 9
  • 10. Page Replacement • Prevent over-allocation of memory • Include page replacement • Use modify (dirty) bit to reduce overhead of page transfers • Each page or a frame may have a modify bit associated with it in the hardware 10
  • 11. Page Replacement • Modify bit for a page is set by the hardware when a word or byte is written to page • Only modified pages are written to disk • Page replacement completes separation between logical memory and physical memory • Large virtual memory can be provided on a smaller physical memory 11
  • 12. Page Replacement Algorithm How to select the page replacement algorithm? • The string of memory references is called reference string • Evaluate the algorithm by running on a reference string and compute the number of page faults • Select the one with lowest page-fault rate 12
  • 13. Page Replacement Algorithm How to determine the no. of page faults? • Need to have the knowledge of number of page frames available for a reference string • As number of page frames increases the page faults will decrease 13
  • 14. FIFO Replacement Algorithms FIFO - First In First Out • Simplest page replacement algorithm • Replace the page that has been in primary memory the longest • FIFO queue holds the pages in memory • Replace the page at the head of the queue • The new page is inserted at the tail of the queue 14
  • 15. FIFO Page Replacement • Page fault’s at 7,0,1,2,3,0,4,2,3,0,1,2,7,0,1 of reference string Fig 3 15
  • 16. FIFO Example : 12 references, 9 faults Fig 4 16
  • 18. FIFO Disadvantages of FIFO algorithm  Performance is not always good  The page in active use is replaced for the new one  This bad replacement choice increases the page faults  To illustrate the problem consider the  Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 18
  • 19. FIFO  3 frames (3 pages can be in memory at a time per process) 1 1 4 55 4 2 2 1 33 1 9 page faults 3 3 2 44 2 Fig 5  4 frames 1 1 5 44 5 2 2 1 55 1 10 page faults 3 3 2 2 4 4 3 3 Fig 6 19
  • 20. Belady's Anomaly • FIFO with 3 page frames Fig : 7 (a) • FIFO with 4 page frames Fig : 7 (b) • P's show which page references show page faults Fig 7 Fig 7 20
  • 21. FIFO  The result is unexpected and is known as Belady’s Anomaly  For some page replacement algorithm Page-fault rate may increase as the no. of allocated frames increase 21
  • 22. Paging Behavior with Increasing Number of Page Frames Fig 8 22
  • 23. FIFO Illustrating Belady’s Anomaly Fig 9 23
  • 24. Summary  In this class, you have learnt  Concepts of Page replacement  FIFO algorithm 24
  • 25. Frequently Asked Questions What is the need for page replacement? How do you find a free frame? What is dirty bit? What is meant by page replacement? Explain FIFO page replacement algorithm 25
  • 26. Quiz 1. Use _____________to reduce overhead of page transfers a) Segmentation b) Modify (dirty) bit c) None 2. Modify bit for a page is _____by the hardware when a word or byte is written to page a) Reset b) Hole c) set d) None 26
  • 27. Quiz 3. ___________completes separation between logical memory and physical memory a) Page number b) MULTICS c) Page replacement d) None 4. Each page or a frame may have a ___________associated with it in the hardware a) External fragmentation b) modify bit c) Compaction d) None 27
  • 28. Quiz 5. What is a Page? a) Blocks of logical memory b) Blocks of physical memory c) Blocks of virtual memory d) None 6. FIFO queue replaces the pages at a) Head of queue b) Tail of queue c) Both d) None 28
  • 29. Quiz 7. ___________completes separation between logical memory and physical memory a) Page number b) MULTICS c) Page replacement d) None 8. Each page or a frame may have a ___________associated with it in the hardware a) External fragmentation b) modify bit c) Compaction d) None 29
  • 30. Other subject materials • Web designing • Micro processors • C++ tutorials • java home