Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 8: Main Memory.

Similar presentations


Presentation on theme: "Chapter 8: Main Memory."— Presentation transcript:

1 Chapter 8: Main Memory

2 Chapter 8: Memory Management
Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium

3 Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only storage CPU can access directly Register access in one CPU clock (or less) Main memory can take many cycles Cache sits between main memory and CPU registers Protection of memory required to ensure correct operation

4 Base and Limit Registers
A pair of base and limit registers define the logical address space

5 Hardware Address Protection with Base and Limit Registers

6 Memory management Memory management and CPU scheduling are perhaps the two most central tasks of an OS Memory consists of a large array of words , each with its own address. Both program and data are stored in memory . Memory is given an address and it returns value .

7 Logical vs. Physical Address Space
The concept of a logical address space that is bound to a separate physical address space is central to proper memory management Logical address – generated by the CPU; also referred to as virtual address Physical address – address seen by the memory unit Logical and physical addresses are the same in compile-time and load-time address-binding schemes; logical (virtual) and physical addresses differ in execution-time address-binding scheme

8 Memory-Management Unit (MMU)
Hardware device that maps virtual to physical address In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory The user program deals with logical addresses; it never sees the real physical addresses

9 Dynamic relocation using a relocation register

10 Swapping A process needs to be in memory to be executed .
* however , it may be temporarily swapped out of memory into a backing store . * the process can later be restarted by swapping it back into memory . * Backing is generally a fast disk. Speed is important . Swapping example :- When a process block or timeout:- 1- swap it out to disk 2- swap in anew (ready ) process from disk to memory 3- dispatch the new process . Another example :- roll out , roll in

11 Schematic View of Swapping

12 Memory Management Requirements
Relocation Programmer cannot know where the program will be loaded in memory when it is executed A program may be relocated (often) in main memory due to swapping Memory references in code (for both instructions and data) must be translated to actual physical memory addresses Chapter 9

13 Memory Management Requirements
Protection Processes should not reference memory locations in another process without permission Cannot do this at compile time, because we do not know where the program will be loaded in memory address references must be checked at run time by hardware Chapter 9

14 Memory Management Requirements
Sharing must allow several processes to access a common portion of data or program without compromising protection cooperating processes may need to share access to the same data structure Program text can be shared by several processes executing the same program for a different user Saves memory over separate copy for each Chapter 9

15 Memory Management Requirements
Physical Organization Memory hierarchy: (several types of memory: from slow and large to small and fast.) main memory for program and data currently in use, secondary memory is the long term store for swapping and paging moving information between levels of memory is a major concern of memory and file management (OS) should be transparent to the application programmer Chapter 9

16 Simple Memory Management
We will look at the following simple memory management techniques : fixed partitioning dynamic partitioning Chapter 9

17 Fixed Partitioning (Single Process)
If only one process allowed (e.g. MS-DOS): only one user partition and one for the OS Not many decisions to make: program either fits or it doesn’t I/O and Interrupt vectors “OperatingSystem” (BIOS) User space 640k Chapter 9

18 Fixed Partitioning Partition main memory into a set of non overlapping regions called partitions Partitions can be of equal or unequal sizes ..both pictures show partitioning of 64 Mmain memory Chapter 9

19 any program smaller than a partition can be loaded into the partition
Fixed Partitioning any program smaller than a partition can be loaded into the partition if all partitions are occupied, the operating system can swap a process out of a partition to make room a program may be too large to fit in a partition. Chapter 9

20 Fixed Partitioning Main memory use is inefficient. Any program, no matter how small, occupies an entire partition. This leaves holes of unused memory inside the partitions: internal fragmentation. Unequal-size partitions can help put small programs in small partitions but there will still be holes... Equal-size partitions was used in early IBM’s OS/MFT (Multiprogramming with a Fixed number of Tasks) Chapter 9

21 Fixed Partitioning Examples


Download ppt "Chapter 8: Main Memory."

Similar presentations


Ads by Google