EEE 435 Principles of Operating Systems - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

EEE 435 Principles of Operating Systems

Description:

Divide memory up into allocation 'units' such as 4 bytes or up to many kilobytes ... for a 64KB unit, if we have a program that is 65KB, then we waste 63 kilobytes! ... – PowerPoint PPT presentation

Number of Views:73
Avg rating:3.0/5.0
Slides: 29
Provided by: mikeles
Category:

less

Transcript and Presenter's Notes

Title: EEE 435 Principles of Operating Systems


1
EEE 435Principles of Operating Systems
  • Basic Memory Management and Page Swapping
  • (Modern Operating Systems 4.1 and 4.2)

2
Quick Review
3
Outline
  • Memory Management Overview
  • Basic Memory Management
  • Monoprogramming
  • Multiprogramming with fixed partitions
  • Swapping
  • Management Bitmaps vs. Linked Lists

4
Memory Management Overview
  • Why do we need to manage memory?
  • How much memory is addressable for a program in
    Windoh!s XP?
  • 4 GB (232 bits)
  • Do most home computers have that much RAM?
  • What do operating systems do when they are
    running programs with memory requirements that
    exceed their capacity?
  • Part or all of the programs are swapped to disk

5
Memory Management Overview
  • Something is needed to manage the movement of
    programs between disk and memory (or, in general
    to manage the memory hierarchy). The part of the
    operating system that does this is known as the
    ________________

6
Memory Management Overview
  • Is multiprogramming worth the hassle of memory
    management?
  • Consider a number of processes which wait for the
    CPU an average of 80 of the time
  • The probability that n processes will all be
    waiting for I/O at the same time in pn. This
    means that the CPU utilization for n processes is
    1-pn
  • Five processes in memory with 80 I/O wait gives
    a CPU utilization of 1-(0.8)5 67 (assuming
    task switch overhead is minimal)
  • Much better than the 20 for a single process!

7
Memory Management Overview
  • Processes with I/O wait in excess of 80 are not
    uncommon!

8
Basic Memory Management
  • First consider two simple systems
  • Monoprogramming
  • Fixed partitions
  • Largely relevant to batch systems
  • Once processes are loaded into memory they are
    run to completion

9
Basic Memory Management
  • Monoprogramming without swapping or paging
  • Simplest scheme possible
  • Only one program will be executed at a time
  • The OS copies the program from disk to memory and
    executes it. Once finished, the OS is ready to
    accept a new command from the user
  • New commands overwrite the old program in memory
    with the new
  • Three configurations, see next slide

10
Basic Memory Management
  • a) is rarely used anymore
  • b) is in use by MP3 players, Palm devices
  • c) was the model of early PCs, eg DOS

11
Basic Memory Management
  • Multiprogramming with fixed partitions
  • To get the benefits of multiprogramming we need
    to be able to have more than one program in
    memory at a time
  • Simple solution (for batch systems) divide
    memory into n (possibly unequal) partitions, and
    put arriving jobs into the smallest partition
    that will hold them (or in line for that
    partition)
  • Disadvantage since partitions are fixed, any
    space not used by a process is lost

12
Basic Memory Management
  • Image shows another disadvantage
  • Since we use multiple queues, we have lineups for
    some partitions, and partitions going completely
    unused!
  • A single queue usually provides superior service
    (like in a bank)

13
Basic Memory Management
  • Many strategies for choosing jobs
  • Allow job closest to the front that can fit into
    the free partition to run
  • Search the whole input queue for the largest job
    that fits
  • Must keep one small partition so small jobs get
    to run!

14
Swapping
  • The previous systems were simpler because once
    programs were loaded into memory they were left
    to run to completion
  • In a timesharing system we cant choose how many
    processes we keep in memory to keep the CPU
    busy...now the user(s) are dictating how many
    processes are executing
  • When not enough main memory exists to hold all
    the active processes we must swap them between
    the disk and main memory...

15
Swapping
  • Swapping a process consists of bringing the
    process into memory, from disk, in its entirety.
    The process is executed for some time and then
    placed back on the disk

16
Swapping
  • The difference between this system and fixed
    partitions is that the number, location, and size
    of the partitions vary dynamically
  • Advantages
  • This is a much more flexible solution
  • Memory can be better utilized
  • Disadvantages
  • More complicated to implement
  • holes can be left in memory which may need
    compacting to correct

17
Swapping How much memory
  • How much memory should be assigned to a process
    when its swapped into memory?
  • If a fixed data size can be determined, then
    exactly that much is used
  • However, if the process has a heap and/or stack,
    then room for growth will be required to prevent
    having to continually moving the program around
    in memory

18
Swapping How much memory
Data and stack segment
  • Data segment

19
Swapping - Management
  • How do we keep track of where processes are
    loaded and where space is available to load them?
  • Two methods Bitmaps and Linked Lists

20
Swapping - Management
  • Memory management with Bitmaps
  • Divide memory up into allocation units such as
    4 bytes or up to many kilobytes
  • Use a bitmap with 1s to designate an allocated
    area of memory and 0s to represent free space
  • How large do we make the allocation unit?

21
Swapping - Management
  • Memory management with Bitmaps
  • The smaller the allocation unit, the larger the
    corresponding bitmap
  • However, even with a 4 byte allocation unit (32
    bits) we only waste 1/33 of the memory
  • Larger units stand to waste the end of the last
    unit, eg for a 64KB unit, if we have a program
    that is 65KB, then we waste 63 kilobytes!
  • However, we have dropped the bitmap overhead to a
    mere 1/512001 1.9x10-4 of memory

22
Swapping - Management
  • Memory management with Bitmaps
  • Advantages
  • Easy to implement
  • Bitmap is a fixed size no matter how many
    programs are in memory
  • Disadvantage
  • can take a long time to search through the bitmap
    to find a consecutive series of 0s in which to
    place a program

23
Swapping - Management
  • Memory management with linked lists
  • Use a linked list to keep track of segments
  • Segments are either processes or a hole between
    two processes convenient to sort by addresses
  • Advantage much less to search through

24
Swapping - Management
  • How do we use the linked list to manage processes
    leaving memory?
  • Simply combine the new hole with all adjacent
    holes

25
Swapping - Management
  • How are new processes placed into memory?
  • __________ Find the first empty segment that is
    large enough to hold the process and break it
    into a process segment and a new hole (smaller
    than the previous one)
  • __________ Simple improvement on first fit.
    Denote the place where the last program was
    inserted and start looking from there
  • Gives slightly worse performance than first fit
    in studies

26
Swapping - Management
  • How are new processes placed into memory?
  • __________ Instead of taking a near fit and
    breaking it into a process segment and a very
    tiny, unusable hole, find the largest available
    hole to leave maximum space for other processes
  • Simulation has shown this to be a truly awful
    choice
  • __________ Keep common entries such as 4KB, 8KB,
    etc in a separate table for easy hole location
  • Good for allocation, but slower for de-allocation
    as multiple lists must be reconciled

27
Swapping - Management
  • Final note on lists you could keep separate
    lists for processes and holes
  • Speeds up looking for a hole!
  • Allows you to sort holes by size for even quicker
    allocation!!
  • Lets you use the actual memory holes themselves
    to hold the pointer information from one hole to
    the next!!!
  • More complicated on de-allocation as your memory
    has to be placed in the correct spot on the other
    list...

28
Quiz Time!
  • Questions?
Write a Comment
User Comments (0)
About PowerShow.com