Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating System Concepts and Techniques Lecture 9 Memory Management-2 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques,

Similar presentations


Presentation on theme: "Operating System Concepts and Techniques Lecture 9 Memory Management-2 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques,"— Presentation transcript:

1 Operating System Concepts and Techniques Lecture 9 Memory Management-2 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.comwww.iUniverse.comwww.barnesandnoble.comwww.amazon.com

2 Multiple Partition MM Multiple partition MM is an extended version of dynamic partition A program can occupy more than one partition of main memory Each module or set of modules can settle in one partition With multiple partition policy comes dynamic linking, or on the fly linking More than one user partition with variable sizes A module could be linked to its calling module the first time it is actually called during run time The called partition need not be adjacent to caller partition To resolve addresses, there is one base address for every linked module, one table of base addresses for every process 2

3 Multiple Partition MM... Advantages Not all the modules will be used every time a software system is executed. Some modules are error handling that may seldom be used Some modules are so that the execution of one excludes the execution of others Therefore, main memory is used economically Disadvantages Linker has to be on duty during execution of the program Execution time increases 3

4 Segmentation MM Most data structures of a program are dynamic in size We cannot reserve enough memory for their growth A program’s address space could be considered a collection of separate segments with each segment being able to grow separately With this methodology, code segment, data segment, and stack of procedure calls and return addresses could each form a separate segment We have a two dimensional view, segment number and offset 4

5 Segmentation MM… The two dimensional view of addresses is transformed to one dimensional view by this memory management and the hardware This is called address translation Perhaps you are familiar with code segment and data segment 5 …. Segment 1 Segment 2 Segment 3 Segment n Offset Program address space

6 Relocatable Partition MM An extension of dynamic partition memory management Relocation of programs is allowed in this new policy When a program is ready to be loaded, if there is no qualified partition, but the total size of all free partitions combined is as large as the size of program, all processes are moved to one end of main memory Base address of programs are adjusted We have to avoid frequent relocation Advantages This policy eliminates external fragmentation Very good for small size memories Disadvantage Relocation imposes high overhead 6

7 Page Memory Management The executable code is chopped up into small equal sized pieces called page Starting from the beginning, pages are numbered from zero on Main memory is also divided into holes of equal sizes called page frames Starting from the beginning, pages frames are numbered from zero on The size of pages and page frames are equal and it is a power of two kilobytes, 1K, 2K, 4K,... 7

8 Pages and page frames 8 Page frame 0 Page frame 6 (a) Main memory (b) A program Page 0 Page 11

9 Page table During the loading of program a page table is produced; it shows what page is in what page frame Page table is used for address translation 9 4 12 13 46 01230123 Page no. Page frame no. Page table of a four-page program

10 Address translation After load, the execution of program is started without any address adjustment Every address generated by program, called logical address, has to be translated to a physical address Address translation is performed by a hardware called memory management unit If a page size is say 2K, address format is 10 31 30 29 … 11 10 9 … 2 1 0 Page number Byte within page

11 Address translation… Address translation The details will be explained later 11 Page number Offset Page frame number Offset Logical address Physical address A fast memory module Offset is directly copied from logical address to physical address Memory management unit

12 Page size Big page size increases internal fragmentation On the average, every program wastes half a page Small page size increases page table size For every page there is one row of page table Somehow we have to minimize memory waste 12

13 Optimal page size Memory waste for every program is Taking its derivative with respect to p and setting it equal to zero, we get Or, where p is the page size in bytes We refine the page size to be a power of 2 in kilo bytes 13

14 Page MM adv./disadv. Advantages Eliminates external Fragmentation Disadvantages Overhead due to address translation Memory waste Program size restriction 14

15 Summary The excellent idea of dynamic link library has evolved from multiple partition MM There are MM policies which are not used for contemporary computers with excellent performance in special environments Relocatable partition MM is often used to manage small size data structures Page MM is the basis for today’s virtual memory In this lecture we studied some non-virtual memory MM policies which support multiprogramming I cannot imagine hundreds of computers that control a sophisticated airplane useing virtual memory 15

16 16 Find out What exactly is the difference between logical and physical addresses The difficulties in having pages that are not a power of two kilobytes Why the size of almost everything a power of two The worst page size in page MM Ways to keep track of available pages of main memory How we can remove all pages of a terminated program from main memory How the page concept could be used within segmentation MM

17 17 Any questions?


Download ppt "Operating System Concepts and Techniques Lecture 9 Memory Management-2 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques,"

Similar presentations


Ads by Google