1 / 14

Operating System Concepts and Techniques Lecture 8

Operating System Concepts and Techniques Lecture 8. Memory Management-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First ed., iUniverse Inc., 2011. To order: www.iUniverse.com , www.barnesandnoble.com , or www.amazon.com. Memory Management (MM).

kstreit
Download Presentation

Operating System Concepts and Techniques Lecture 8

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating System Concepts and Techniques Lecture 8 Memory Management-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First ed., iUniverse Inc., 2011. To order: www.iUniverse.com, www.barnesandnoble.com, or www.amazon.com

  2. Memory Management (MM) • Memory management policies and techniques have tremendously changed throughout the years • The simplest being single contiguous partition memory management • The most complex being multilevel-page table virtual memory with cache • A Brief list follows

  3. A Brief list of MM policies

  4. Single contiguous partition MM • MM is divided into two parts • One part for operating system • The other is called user memory • So simple that there is no MM subsystem, loader takes care of it • Make sure user program does not destroy OS • Many disadvantages • Supports only single-programming • System utilization is very low • Waste of memory for small programs • A program larger than the user’s main memory will not be able to run

  5. Static Partition MM • More than one user partition with fixed sizes • Sizes are different to reduce memory waste and accept larger programs • Make sure user programs do not interfere and do not destroy OS • Number of partitions determines degree of multiprogramming • Advantages • Simple to implement; a table for partitions information • Multiprogramming is possible • the size of runable programs limited to the largest partition size • Memory waste • A program larger than users main memory will not be able to run

  6. Dynamic Partition MM • More than one user partition with variable sizes • Sizes are different to reduce memory waste and accept larger programs • Make sure user programs do not interfere and do not destroy OS • Number of partitions determines the degree of multiprogramming • At start there is only one big free partition • When new programs are accepted new partitions are created • Upon program completion free neighbor partitions can join • Advantages • Simple to implement; two tables, free and allocated partitions • Multiprogramming is possible • The size of a runable programs limited to the size of user memory • A program larger than users main memory will not be able to run

  7. Dynamic Partition Memory waste • There is a smallest memory allocation unit, usually 1K bytes • A program which is 1025 bytes will be given 2K bytes, 1023 bytes are wasted in the form of internal fragmentation • We are not allowed to relocate programs • External fragmentationoccurs when all free memory partitions combined are large enough to load the coming program into, but these spaces do not form a contiguous partition and each one cannot accept the coming program

  8. Dynamic Partition Memory waste… • The 50% rule: Without other information, on the average, the number of free partitions is half the number of allocated partitions • Remember: adjacent free partitions join, but adjacent occupied partitions house different programs • Let C = (average free partition size)/(average program size), then external fragmentation fraction=

  9. Partition allocation • First-Fit • Look at the free partitions data structure (not the main memory itself) and select the first which is as large as the program • Next-Fit • From partitions data structure, from where the pointer points, select the first which is as large as the program • Best-Fit • pick a qualified partition whose size is closest to the size of the program • Worst-Fit • Pick the largest free partition

  10. Partition allocation- Buddy syatem • The size of a partition is 2i*m • A partition size of 2i*K could split into two size 2i-1*K which are called buddies • Remember that any two partition of size 2i*m are not buddies even if they are adjacent • A complete partition is given to a program • Remember partitions cannot start from any arbitrary address • A program the size of xK is given a partition of size 2i*K, where 2i  x and i is the smallest such integer • Any two free buddies have to merge

  11. 512M 256M 128M 64M 32M : Processed : Allocated : Available Buddy system tree Figure shows certain state of a small 512 Mega Bytes (MB) main memory. A black circle represents a partition that has been broken and no longer exists. Dark circles represent a partition that is occupied by a program. An unfilled circle represents a free (available) partition Advantage: easy to find a partition for a program Disadvantage: Internal fragmentation increases

  12. Summary • There are variety of memory management • The simplest, single contiguous memory management • The most complex, multilevel page table page-based virtual memory with segmentation and cache memory • Older managements are good for special purpose computer such as embedded control systems and intelligent machinery electronics • This lecture introduced static and dynamic partition memory managements • Base register is a central concept to dynamic partition MM

  13. Find out • What the degree of multiprogramming is in your computer • Practical systems which use single partition MM • If we can have a buddy system in which buddies are not the same size • In buddy system, why can’t any two adjacent partitions the size of 2i*K, join to form a partition the size of 2i+1*K • In what situations worst-fit will perform better than other partition selection algorithms

  14. Any questions?

More Related