operating systems - memory, files

Upload: webtimi

Post on 09-Apr-2018

250 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Operating Systems - Memory, Files

    1/46

    Memory ManagementRobert Dickerson

  • 8/8/2019 Operating Systems - Memory, Files

    2/46

    Why is it generally inefficient to allow onlyone process to be in memory at a time?

  • 8/8/2019 Operating Systems - Memory, Files

    3/46

    If the single process blocks for I/O, noother processes can use the processor

    Answer

  • 8/8/2019 Operating Systems - Memory, Files

    4/46

    What would happen if a system allowedmany processes to be placed in mainmemory, but did not divide memory into

    partitions?

  • 8/8/2019 Operating Systems - Memory, Files

    5/46

    The processes would all share their

    memory

    Any malfunctioning or malicious processcould damage any or all of the other

    processes

    Answer

  • 8/8/2019 Operating Systems - Memory, Files

    6/46

    Name the two types offetch strategies

    Describe when one might be moreappropriate than the other

  • 8/8/2019 Operating Systems - Memory, Files

    7/46

    Demand fetch andanticipatory fetch

    If the system cannot predict future memoryusage with accuracy, then the loweroverhead of demand fetching results in

    higher performance and utilization

    If program exhibits predictable behavior,anticipatory fetch strategy is best

  • 8/8/2019 Operating Systems - Memory, Files

    8/46

    When is noncontiguous preferable tocontiguous memory allocation?

    Contiguous vs.

    Noncontiguous Memory

  • 8/8/2019 Operating Systems - Memory, Files

    9/46

    Answer

    Noncontiguous is better when availablememory contains no area large enough to

    hold the incoming program in a contiguous

    piece

  • 8/8/2019 Operating Systems - Memory, Files

    10/46

    What sort of overhead is involved in a

    noncontiguous memory allocation

    scheme?

  • 8/8/2019 Operating Systems - Memory, Files

    11/46

    You need to store:

    available blocks

    blocks that belong to separate processes

    where those blocks reside in memory

  • 8/8/2019 Operating Systems - Memory, Files

    12/46

    Describe the benefits and drawbacks oflarge and small partition sizes

  • 8/8/2019 Operating Systems - Memory, Files

    13/46

    Larger partitions allow large programsto run, but result in internal fragmentation

    for small programs

    Small partitions reduce the amount ofinternal fragmentation and increase the

    level of multiprogramming by allowing more

    programs to reside in memory at once

  • 8/8/2019 Operating Systems - Memory, Files

    14/46

    Explain the difference between internaland external fragmentation

  • 8/8/2019 Operating Systems - Memory, Files

    15/46

    Internal fragmentation occurs infixed-partition environments when a

    process is allocated more space that it

    needs.

    External fragmentation occurs invariable-partition environments when

    memory is wasted to holes developing inmemory between partitions.

  • 8/8/2019 Operating Systems - Memory, Files

    16/46

    Why are segmentation/pagingsystems appealing?

  • 8/8/2019 Operating Systems - Memory, Files

    17/46

    Segmentation/paging offers architectural

    simplicity of paging and access control

    capabilities of segmentation

  • 8/8/2019 Operating Systems - Memory, Files

    18/46

    Why are large page sizes more favorable in

    todays systems than they were decades

    ago?

  • 8/8/2019 Operating Systems - Memory, Files

    19/46

    Cost of memory is cheaper, applicationsmore memory intensive

    Cost of internal fragmentation is less of aconcern

    Large pages require the system to perform

    fewer costly I/O operations

  • 8/8/2019 Operating Systems - Memory, Files

    20/46

    What restriction does assembly time

    or load time binding of address place

    on the swapping of a process?

  • 8/8/2019 Operating Systems - Memory, Files

    21/46

    If addresses are not bound at runtime, thenthe process must be swapped into thesame memory location from which it was

    swapped out

  • 8/8/2019 Operating Systems - Memory, Files

    22/46

  • 8/8/2019 Operating Systems - Memory, Files

    23/46

    Compaction - if addresses can be boundat runtime, we can move the used memoryaround so that the unused memory is

    contiguous and reset the base register.

    Break a process into 2 or more smallersections to increase likelihood small

    memory spaces will be used

    Loosen the requirement that processmemory be contiguous. Solution- paging

  • 8/8/2019 Operating Systems - Memory, Files

    24/46

    What is a TLB?

  • 8/8/2019 Operating Systems - Memory, Files

    25/46

    Translation Look-aside Buffer hardware method of speeding up

    translation of logical to physical memory

    addresses

    acts as a cache for more recent translations

    page number is compared to all page-framepairs in parallel - very fast!

  • 8/8/2019 Operating Systems - Memory, Files

    26/46

    What is involved with a context switch?

  • 8/8/2019 Operating Systems - Memory, Files

    27/46

    Occurs when a process is interrupted andanother process gains control of the

    system

    Save registers, program counter, page tableor segment pointers, stack, etc.

  • 8/8/2019 Operating Systems - Memory, Files

    28/46

  • 8/8/2019 Operating Systems - Memory, Files

    29/46

    compiled into separate units(code, data, stack)

    user specifies a segment number and offsetinstead of an address.

    Segments can have variable lengths

    requires a field in segment tablecontaining the limits of the offset value

  • 8/8/2019 Operating Systems - Memory, Files

    30/46

    What property must code have in able tobe shared?

  • 8/8/2019 Operating Systems - Memory, Files

    31/46

    It must be reenterant

    A computer program or routine is described asreentrant if it can be safely called recursively andconcurrently from multiple processes.

    To be reentrant, a function must:

    hold no static data

    must not return a pointer to static data, must work only on the data provided to it by

    the caller, and must not call non-reentrant

    functions.

    http://en.wikipedia.org/wiki/Concurrency_%28computer_science%29http://en.wikipedia.org/wiki/Computer_programhttp://en.wikipedia.org/wiki/Subroutinehttp://en.wikipedia.org/wiki/Concurrency_%28computer_science%29http://en.wikipedia.org/wiki/Concurrency_%28computer_science%29http://en.wikipedia.org/wiki/Recursion_%28computer_science%29http://en.wikipedia.org/wiki/Recursion_%28computer_science%29http://en.wikipedia.org/wiki/Subroutinehttp://en.wikipedia.org/wiki/Subroutinehttp://en.wikipedia.org/wiki/Computer_programhttp://en.wikipedia.org/wiki/Computer_program
  • 8/8/2019 Operating Systems - Memory, Files

    32/46

    What is virtual memory?

  • 8/8/2019 Operating Systems - Memory, Files

    33/46

    Allows execution of processes that may notbe completely in memory.

    Allows programmers to think of memoryas a large uniform space

  • 8/8/2019 Operating Systems - Memory, Files

    34/46

    Why is virtual memory almost never usedin a realtime system?

  • 8/8/2019 Operating Systems - Memory, Files

    35/46

    Dependability of the system

    Predictable in time required to complete

    operations

    Virtual memory creates less predictabledelays in memory-related operations

  • 8/8/2019 Operating Systems - Memory, Files

    36/46

    What happens on a page fault?

  • 8/8/2019 Operating Systems - Memory, Files

    37/46

    Page table for the process is used todetermine if the page corresponding tological address is invalid

    If it is, OS chooses a free frame or selects apage to be paged out, and gets the pagefrom backing store

    Page table is updated to reflect that page isnow in memory and instruction is restarted

  • 8/8/2019 Operating Systems - Memory, Files

    38/46

    What is Beladys Anomoly?

  • 8/8/2019 Operating Systems - Memory, Files

    39/46

    Beladys anomaly states it is possible tohave more page faults when increasing the

    number of page frames while using FIFO

    method of frame management.

    Previously, it was believed that an increasein the number of page frames would always

    provide the same or fewer page faults

  • 8/8/2019 Operating Systems - Memory, Files

    40/46

    example

    3 2 1 0 3 2 4 3 2 1 0 4

    3 page frames

  • 8/8/2019 Operating Systems - Memory, Files

    41/46

    Why is it that no page replacementalgorithm can be optimal?

  • 8/8/2019 Operating Systems - Memory, Files

    42/46

    Optimal algorithms would be where thepage that will not be used for the longest

    time will be swapped out

    No algorithm can be optimal because it isimpossible to foresee the future page usage

  • 8/8/2019 Operating Systems - Memory, Files

    43/46

    How do you implement aLRU page replacement?

  • 8/8/2019 Operating Systems - Memory, Files

    44/46

  • 8/8/2019 Operating Systems - Memory, Files

    45/46

    What is an inverted page table?

  • 8/8/2019 Operating Systems - Memory, Files

    46/46

    Instead of mapping virtual page to a frame,map the frames to the pages

    Results in a table whose number of entriescorresponds to the number of frames