Docsity

Memory Management - Computer Science and Engineering - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Memory Management - Computer Science and Engineering - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

MEMORY

MANAGEMENT

Operating System

A

operating

system

is

a^

set

of

master

programs

which

is

desired

to

control

entire

operations of computer. Operating System is ageneral purpose software which is involved ineach and every activity of the computer. Thevarious functions of operating system are•Interface between user and hardware•Peripheral Management•Memory Management•Process Management

Principals of Memory Management

The various aim and principals of memorymanagement are•To

provide

the

memory

space

to

enable

many

processes

to

be

executed

at

same

time.•To protect the processes from each other.•To provide satisfactory level as performanceto users.•To

make

addressing

of

memory

space

transparent for an programmer.

Address Binding

Each program resides on a disk but it must bebrought to memory for execution. The processhas to be moved between disk and memory.Thus different memory address are used atdifferent location. The process of

changing

the addresses during storage is called binding.The various types of binding are1. Compile Time Binding2. Load Time Binding3. Execution Time Binding

Relocation

The

logical

addresses

are

converted

into

physical

addresses by the help of relocation

register present in Memory Management Unitor by relocating linkers and loader. The abilityto

load

and

execute

a^

given

program

to

arbitrary place in memory is called relocation.The

user

program

supplies

logical

address

must be mapped to physical addresses beforethey are used. The types of Relocation are1. Static Relocation2. Dynamic Relocation

Relocation

The types of Relocation are1. Static Relocation :- The Static Relocation is

performed before or during the loading ofprogram

into

memory.

This

is

done

by

relocating linkers and relocating loaders.

  1. Dynamic

Relocation

:-^

The

Dynamic

relocation is performed during the executionof the program. This is done by the help ofthe

hardware

support

called

Memory

management Unit (MMU).

Partitioning

The

Operating

System

manages

the

main

memory by dividing the memory into regions offixed or variable size is called Partitioning. Itmanages the main memory efficiently. The twotypes of partitions are1. Static

Partition:-

The

whole

memory

is

divided into fixed sized frame is called staticpartition.

  1. Dynamic Partition:- The memory is divided

into variable sized frame according to pagesize is called dynamic partition.

Partitioning

Example

0

0

10

10

15

15

20 30

33

3840

40

4750

50

Static Partition

Dynamic Partition

P1P2 P3 P3 P

process space

P

10

P

5

P

18

P

7

P1 P2 P3 P

Contiguous Memory Allocation

Each

logical

object

is

placed

in

physical

memory

at

consecutive

addresses

is

called

contiguous

memory

allocation.

Generally

memory

is

partitioned

and

any

process

requesting memory is allocated a partition. Ontermination, process release memory partitionto a free pool of memory. There are number ofscheme which can be used for a system butwe can rate efficiency of a particular memorymanagement

scheme

like

wasted

memory,

time complexity, memory access overheads.

Static Partitioned Memory Allocation

The memory partition are created sometimebefore the execution of user programs thesepartitions

remain

fixed.

This

approach

is

known

as

Static

Partitioned

Memory

Allocation. The number and size of partitions isfixed

during

system

generation

process

by

considering1. Capacity of memory,2. Degree of multiprogramming,3. Size of program.

Algorithms

  1. First

Fit:-

OS

searches

the

first

partition

large enough to store process.

  1. Next

Fit:-

The

memory

manager

keep

a

pointer on the free list to store process.

  1. Best Fit:- Memory manager searches free

list from beginning to end and selects thesmallest possible portion to hold process.

  1. Worst Fit:- The memory manager scans the

free list and allocate the largest memoryblock to create partition to store process.

Swapping

The process of a suspended or preemptedprocess in main memory with a new process iscalled swapping. When all memory partitionshave

been

allocated

and

there

is

need

to

allocate a partition to a process, a suspendedor preempted processes is taken out from thememory

in

order

to

bring

new

process.

Swapping

is

used

to

implement

the

multi

programming in the system which have lesshardware support for memory management.Swapping is done by module called Swapper

Compaction

The process of relocating all partitions into oneend of memory and to combine holes into largefree

area

is

called

compaction.

When

the

memory becomes fragmented, solution is

to

relocate

all

partition

into

one

end

using

compaction.

All

the

effected

processes

are

suspended and they are copied from one toanother area of memory. It can be performedwhenever

possible

or

only

when

needed.

System compacts memory when large free areais return or there is failure to allocate memory.

docsity.com

Paging

Paging is a memory management scheme thatpermits

the

physical

address

space

of

a

process

to

be

non

contiguous.

In

paging

physical memory is divided into fixed sizedpartitions called frames. Virtual address spaceis also divided into blocks of same size calledpages. A page map table is used for addresstranslation. The virtual address of a process isdivided into two parts that are1. Page number (p)2. Page offset (d)