MEMORY MANAGEMENT By KUNAL KADAKIA RISHIT SHAH
Dec 21, 2015
MEMORY MANAGEMENT
By
KUNAL KADAKIA
RISHIT SHAH
Memory • Memory is a large array of words or bytes, each with
its own address. It is a repository of quickly accessible data shared by the CPU and I/O devices.
• Operating system’s task is to allow accommodation of multiple processes in the memory.
• Memory needs to be allocated efficiently in order to allow as many processes into memory as possible.
• If not enough process are in memory, multiprogramming will not be effective and CPU will be idle for a large part of the time.
• In most OS, the kernel occupies some part of main memory and the rest is shared by multiple process.
Basics • Memory is divided into primary memory and secondary
memory.• Primary memory holds information while it is being used by
the CPU. The primary memory are:• Faster to Access• Relatively High storage cost per bit• Volatile• Stores only running program and data currently in use
• Secondary memory refers to the collection of storage devices. They are
• Slower• Cheaper than primary Memory• Usually not volatile• Large capacity for Long term storage of programs and
data
Storage Hierarchy
Storage Hierarchy • A von Neumann computer’s memory is also
organized as a storage hierarchy.
Storage Device Hierarchy
Memory Manager
• The part of the OS that manages the memory hierarchy is called the memory manager.
• Its job is to keep track of which parts of the memory are in use and which are not in use.
• It is the resource manager for the primary memory
Memory Manager• The classic Memory Manager addresses primary
memory management by implementing
a) Abstraction : The primary memory is abstracted so that software perceives the memory allocated to it as a large array of contiguously addressed bytes.
b) Allocation: A process may request exclusive use of block of memory.
c) Isolation: When a block of memory is allocated to a process, the process is assured of exclusive use of those memory cells.
d) Sharing: The memory manager may permit a block of primary memory to be shared among two or more processes.
The Address Space Abstraction
• For multiprogramming OS, each process is provided with a set of logical primary memory address that it can use to read or write locations in the physical primary memory.
• The accessible addresses are the one that have been assigned to the process by the memory manager.
• This set of logical primary memory addresses is referred as process address space.
• When a thread executes in the process, it can use any of the logical primary memory addresses to reference a specific block of physical primary memory.
The Address Space Abstraction
Fig The relationship between the address space and primary memory.
When a block of primary memory is associated to a process, the process's address space is bound to the block of the corresponding physical memory address.
Managing The Address Space
• When a program is prepared for execution, it is translated into a machine executable format as shown below
Managing The Address Space
• The source program is translated at compile time to produce a relocatable object module.
• A collection of relocatable modules is combined using a linkage editor to produce an absolute module.
• The absolute program is stored in a file until a process is ready to use.
• The organization of the absolute module defines the address space that the process will use to reference the program’s instructions, data, and stack.
• After a process has obtained a block of primary memory from the memory manager, it calls the system loader to place the absolute program into that block of primary memory.
Modern memory Binding• Generally each process is created with a large, empty
address space: say a 4 GB address space. • In OS such as Linux and Windows, the address space
is partitioned into a segment that is used by a user space program, and another segment that is used when the process is used in supervisor mode.
• A typical partition allows the process to use 3 GB of the address when it is in user mode and 1 GB when it is in supervisor mode.
Modern memory Binding
Memory Allocation
Fixed partition memory strategies
Variable partition memory strategies
Memory Allocation
Memory Allocation
Memory Allocation
Memory Allocation
Memory Allocation
• Multiple Queues
• Assigns each processto the smallest partition within which it fits.
• Minimizes internal fragmentation.
• Memory not used efficiently if many process in one class and few in another
Memory Allocation
• Single Queue• Assign each process to the
smallest available partition within which it fits.
• Increases the level of multiprogramming o the expense of internal fragmentation.
• Small processes can use up a big partition, again memory not used efficiently.
Memory Allocation
Memory Allocation
Memory Allocation
Memory Allocation
• External fragmentation
Memory Allocation
Memory Allocation
• Compaction leads to increase in the cost of moving process.
• Hence evolved the dynamic address space binding approach.
Dynamic address space binding
• We need a tool for binding address at runtime.
• Hence we use a method called dynamic address relocation.
Hardware dynamic address relocation
Multiple segment relocation registers
Bound checking with a limit register
Modern memory management strategies
• Virtual memory
• Swapping
Swapping
Other important issue
• Cache memory CPU
Cache memory
Memory Device
References
• Operating systems, Garry Nutt
• WWW
THANK YOU