Modeling Page Replacement Algorithms

Embed Size (px)

Citation preview

  • 7/28/2019 Modeling Page Replacement Algorithms

    1/22

    I.S.L Sarwani,

    Asst prof, IT,

    ANITS

    Modeling Page Replacement

    Algorithms

  • 7/28/2019 Modeling Page Replacement Algorithms

    2/22

    Modeling Page Replacement Algorithms

    Belady's Anomaly

    FIFO with 3 page frames FIFO with 4 page frames

    P's show which page references show page faults

  • 7/28/2019 Modeling Page Replacement Algorithms

    3/22

    Stack Algorithms

    State of memory array, M, after each item in reference stringis processed

  • 7/28/2019 Modeling Page Replacement Algorithms

    4/22

    Contd..

    Paging system can be categorized by 3 items:

    1. The reference string of executing process

    2. the page replacement algorithm

    3. the number of page frames available in memory i.e.

    mM- internal array keeps track of state of memory

    Top part- all the page entries currently in memory

    Bottom part- pages referenced once, swapped out and

    are not in memory

  • 7/28/2019 Modeling Page Replacement Algorithms

    5/22

    The Distance String

    A page reference will be denoted by the distance

    from top of stack where reference page was

    located.

    Pages that have not yet been reference distance infinity.

    Distance string depends on reference string and

    paging algorithm.

  • 7/28/2019 Modeling Page Replacement Algorithms

    6/22

    Predicting page fault rates

    Computation of page fault rate from distance string the Cvector

    the Fvector

  • 7/28/2019 Modeling Page Replacement Algorithms

    7/22

    Contd..C number of occurrences of i or infinity in distance

    string

    F number of page faults

  • 7/28/2019 Modeling Page Replacement Algorithms

    8/22

    Design issues for paging systems

  • 7/28/2019 Modeling Page Replacement Algorithms

    9/22

    Local versus Global Allocation Policies (1)

    Original configuration Local page replacement

    Global page replacement

  • 7/28/2019 Modeling Page Replacement Algorithms

    10/22

    Local when a process gets page fault , the

    page replacement algorithm try to find the LRU

    page considering pages that are currently

    allocated to only that process.

    Global if the page with lowest age value is

    removed without regard to whose page it is.

  • 7/28/2019 Modeling Page Replacement Algorithms

    11/22

    Contd..

    Local allocates fixed memory to process.

    If working set grows thrashing will result. So

    wasting memory.

    Global dynamical allocation among runnable

    processes.Here OD continually decides how many page

    frames to assign to each process.

    Page Fault Frequency (PFF) algorithm: Tells when

    to increase or decrease process page allocation but

    not which page to remove

  • 7/28/2019 Modeling Page Replacement Algorithms

    12/22

    Load Control

    Despite good designs, system may still thrash

    When PFF algorithm indicates some processes need more memory

    but no processes need less

    Solution :

    Reduce number of processes competing for memory

    swap one or more to disk, divide up pages they held reconsider degree of multiprogramming

  • 7/28/2019 Modeling Page Replacement Algorithms

    13/22

    Page Size (1)

    Small page size Advantages

    less internal fragmentation

    better fit for various data structures, code sections

    less unused program in memory

    Disadvantages

    programs need many pages, larger page tables

  • 7/28/2019 Modeling Page Replacement Algorithms

    14/22

    Separate Instruction and Data Spaces

    One address space Separate I and D spaces

  • 7/28/2019 Modeling Page Replacement Algorithms

    15/22

    Shared Pages

    Two processes sharing same program sharing its

    page table

  • 7/28/2019 Modeling Page Replacement Algorithms

    16/22

    Contd..

    If I space and D space are supported 2 or

    more processes use the same page table for

    their I space but different D space.

    Processes share same code problem occurs

    Copy-on-write: Those pages that are never

    written need not be copied.

  • 7/28/2019 Modeling Page Replacement Algorithms

    17/22

    Cleaning Policy

    Need for a background process, paging daemon periodically inspects state of memory

    When too few frames are free

    selects pages to evict using a replacement algorithm

    It can use same circular list (clock)

    front hand controlled by paging daemon Back hand page replacement

  • 7/28/2019 Modeling Page Replacement Algorithms

    18/22

    Segmentation

  • 7/28/2019 Modeling Page Replacement Algorithms

    19/22

    Segmentation (1)

    One-dimensional address space with growing tables

    One table may bump into another

  • 7/28/2019 Modeling Page Replacement Algorithms

    20/22

    Segmentation (2)

    Allows each table to grow or shrink, independently

  • 7/28/2019 Modeling Page Replacement Algorithms

    21/22

    Segmentation (3)

    Comparison of paging and segmentation

  • 7/28/2019 Modeling Page Replacement Algorithms

    22/22

    Implementation of Pure Segmentation

    (a)-(d) Development of checkerboarding

    (e) Removal of the checkerboarding by compaction