Top Banner
MEMORY MANAGEMENT By KUNAL KADAKIA RISHIT SHAH
36

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.

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 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.

MEMORY MANAGEMENT

By

KUNAL KADAKIA

RISHIT SHAH

Page 2: 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.

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.

Page 3: 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.

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

Page 4: 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.

Storage Hierarchy

Page 5: 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.

Storage Hierarchy • A von Neumann computer’s memory is also

organized as a storage hierarchy.

Page 6: 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.

Storage Device Hierarchy

Page 7: 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.

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

Page 8: 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.

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.

Page 9: 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.

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.

Page 10: 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.

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.

Page 11: 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.

Managing The Address Space

• When a program is prepared for execution, it is translated into a machine executable format as shown below

Page 12: 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.

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.

Page 13: 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.

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.

Page 14: 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.

Modern memory Binding

Page 15: 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.

Memory Allocation

Fixed partition memory strategies

Variable partition memory strategies

Page 16: 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.

Memory Allocation

Page 17: 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.

Memory Allocation

Page 18: 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.

Memory Allocation

Page 19: 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.

Memory Allocation

Page 20: 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.

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

Page 21: 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.

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.

Page 22: 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.

Memory Allocation

Page 23: 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.

Memory Allocation

Page 24: 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.

Memory Allocation

Page 25: 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.

Memory Allocation

• External fragmentation

Page 26: 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.

Memory Allocation

Page 27: 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.

Memory Allocation

• Compaction leads to increase in the cost of moving process.

• Hence evolved the dynamic address space binding approach.

Page 28: 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.

Dynamic address space binding

• We need a tool for binding address at runtime.

• Hence we use a method called dynamic address relocation.

Page 29: 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.

Hardware dynamic address relocation

Page 30: 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.

Multiple segment relocation registers

Page 31: 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.

Bound checking with a limit register

Page 32: 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.

Modern memory management strategies

• Virtual memory

• Swapping

Page 33: 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.

Swapping

Page 34: 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.

Other important issue

• Cache memory CPU

Cache memory

Memory Device

Page 35: 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.

References

• Operating systems, Garry Nutt

• WWW

Page 36: 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.

THANK YOU