SlideShare a Scribd company logo
1 of 25
Memory Management inMemory Management in
Operating SystemsOperating Systems
V.V. SubrahmanyamV.V. Subrahmanyam
SOCIS, IGNOUSOCIS, IGNOU
Date: 31Date: 31stst
March, 2008March, 2008
Time: 19-00 to 19-45Time: 19-00 to 19-45
MemoryMemory
 Memory is central to the operation of a modernMemory is central to the operation of a modern
computer system.computer system.
 Memory is a large array of words or bytes, eachMemory is a large array of words or bytes, each
location with its own address.location with its own address.
 Interaction is achieved through a sequence ofInteraction is achieved through a sequence of
reads/writes of specific memory address.reads/writes of specific memory address.
 The CPU fetches the program from the hard diskThe CPU fetches the program from the hard disk
and stores in the memory.and stores in the memory.
 If a program is to be executed, it must beIf a program is to be executed, it must be
mapped to absolute addresses and loaded intomapped to absolute addresses and loaded into
memory.memory.
Contd…Contd…
 In a multiprogramming environment, in order toIn a multiprogramming environment, in order to
improve both the CPU utilisation and the speedimprove both the CPU utilisation and the speed
of the computer’s response, several processesof the computer’s response, several processes
must be kept in memory.must be kept in memory.
 There are many different algorithms dependingThere are many different algorithms depending
on the particular situation to manage theon the particular situation to manage the
memory.memory.
 Selection of a memory management scheme forSelection of a memory management scheme for
a specific system depends upon many factors,a specific system depends upon many factors,
but especially upon the hardware design of thebut especially upon the hardware design of the
system.system.
 Each algorithm requires its own hardwareEach algorithm requires its own hardware
support.support.
Memory Management –Memory Management –
Responsibilities of OSResponsibilities of OS
 Keep track of which parts of memory areKeep track of which parts of memory are
currently being used and by whom.currently being used and by whom.
 Decide which processes are to be loadedDecide which processes are to be loaded
into memory when memory spaceinto memory when memory space
becomes available.becomes available.
 Allocate and deallocate memory space asAllocate and deallocate memory space as
needed.needed.
Contd…Contd…
 In the multiprogramming environmentIn the multiprogramming environment
operating system dynamically allocatesoperating system dynamically allocates
memory to multiple processes.memory to multiple processes.
 Thus memory plays a significant role inThus memory plays a significant role in
the important aspects of computer systemthe important aspects of computer system
like performance, S/W support, reliabilitylike performance, S/W support, reliability
and stability.and stability.
OverlaysOverlays
 In idealistic situation, the entire program and itsIn idealistic situation, the entire program and its
related data is loaded in physical memory forrelated data is loaded in physical memory for
execution.execution.
 But what if process is larger than the amount ofBut what if process is larger than the amount of
memory allocated to it?memory allocated to it?
 We can overcome this problem by adopting aWe can overcome this problem by adopting a
technique called astechnique called as OverlaysOverlays. Like dynamic. Like dynamic
loading, overlays can also be implemented byloading, overlays can also be implemented by
users without OS support.users without OS support.
 The entire program or application is divided intoThe entire program or application is divided into
instructions and data sets such that when oneinstructions and data sets such that when one
instruction set is needed it is loaded in memoryinstruction set is needed it is loaded in memory
and after its execution is over, the space isand after its execution is over, the space is
released.released.
 As and when requirement for other instructionAs and when requirement for other instruction
arises it is loaded into space that was releasedarises it is loaded into space that was released
previously by the instructions that are no longerpreviously by the instructions that are no longer
needed.needed.
 Such instructions can be called as overlays,Such instructions can be called as overlays,
which are loaded and unloaded by the program.which are loaded and unloaded by the program.
 DefinitionDefinition: An overlay is a part of an: An overlay is a part of an
application, which has been loaded at sameapplication, which has been loaded at same
origin where previously some other part (s) oforigin where previously some other part (s) of
the program was residing.the program was residing.
 A program based on overlay scheme mainlyA program based on overlay scheme mainly
consists of following:consists of following:
 A “root” piece which is always memory residentA “root” piece which is always memory resident
 Set of overlays.Set of overlays.
 Overlay gives the program a way to extendOverlay gives the program a way to extend
limited main storage. An important aspectlimited main storage. An important aspect
related to overlays identification in program isrelated to overlays identification in program is
concept of mutual exclusion i.e., routines whichconcept of mutual exclusion i.e., routines which
do not invoke each other and are not loaded indo not invoke each other and are not loaded in
memory simultaneously.memory simultaneously.
Example of OverlayExample of Overlay
Read ( )
Function1 ( )
Function2 ( )
Display ( )
Read ( )
Display ( )
Function2 ( )Function1()
20 K
20K Read( ) Read ( )
50K Function1( )
Function 1( ) Function 2( )
70K Function 2( )
Overlay A 40K Display ( ) Overlay B
40K Display ( ) (50K) (70K)
Without Overlay (180K) With Overlay (Maximum.130K)
Limitations of OverlaysLimitations of Overlays
Overlays scheme suffers from following limitations:Overlays scheme suffers from following limitations:
 Require careful and time-consuming planning.Require careful and time-consuming planning.
 Programmer is responsible for organizingProgrammer is responsible for organizing
overlay structure of program with the help of fileoverlay structure of program with the help of file
structures etc. and also to ensure that piece ofstructures etc. and also to ensure that piece of
code is already loaded when it is called.code is already loaded when it is called.
 Operating System provides the facility to loadOperating System provides the facility to load
files into overlay region.files into overlay region.
SwappingSwapping
 Swapping is an approach for memorySwapping is an approach for memory
management by bringing each process inmanagement by bringing each process in
entirety, running it and then putting it back on theentirety, running it and then putting it back on the
disk, so that another program may be loadeddisk, so that another program may be loaded
into that space.into that space.
 Swapping is a technique that lets you use a diskSwapping is a technique that lets you use a disk
file as an extension of memory.file as an extension of memory.
 Lower priority user processes are swapped toLower priority user processes are swapped to
backing store (disk) when they are waiting forbacking store (disk) when they are waiting for
I/O or some other event like arrival of higherI/O or some other event like arrival of higher
priority processes. This ispriority processes. This is Rollout SwappingRollout Swapping..
 Swapping the process back into store whenSwapping the process back into store when
some event occurs or when needed (may be in asome event occurs or when needed (may be in a
different partition) is known asdifferent partition) is known as Roll-in swappingRoll-in swapping..
SwappingSwapping
Operating System
User
Process/Application
ProcessP1
ProcessP2
Main Memory Disk
Roll Out
Roll In
Benefits of SwappingBenefits of Swapping
 Allows higher degree of multiprogramming.Allows higher degree of multiprogramming.
 Allows dynamic relocation, i.e., if addressAllows dynamic relocation, i.e., if address
binding at execution time is being used we canbinding at execution time is being used we can
swap in different location else in case of compileswap in different location else in case of compile
and load time bindings processes have to beand load time bindings processes have to be
moved to same location only.moved to same location only.
 Better memory utilisation.Better memory utilisation.
 Less wastage of CPU time on compaction, andLess wastage of CPU time on compaction, and
 Can easily be applied on priority-basedCan easily be applied on priority-based
scheduling algorithms to improve performance.scheduling algorithms to improve performance.
LimitationsLimitations
 Entire program must be resident in storeEntire program must be resident in store
when it is executing.when it is executing.
 Also processes with changing memoryAlso processes with changing memory
requirements will need to issue systemrequirements will need to issue system
calls for requesting and releasing memory.calls for requesting and releasing memory.
 It is necessary to know exactly how muchIt is necessary to know exactly how much
memory a user process is using and alsomemory a user process is using and also
that it is blocked or waiting for I/O.that it is blocked or waiting for I/O.
Logical and Physical AddressLogical and Physical Address
SpaceSpace
 The computer interacts via logical and physicalThe computer interacts via logical and physical
addressing to map memory.addressing to map memory.
 Logical address is the one that is generated byLogical address is the one that is generated by
CPU, also referred to as virtual address. TheCPU, also referred to as virtual address. The
program perceives this address space.program perceives this address space.
 Physical address is the actual addressPhysical address is the actual address
understood by computer hardware i.e., memoryunderstood by computer hardware i.e., memory
unit. Logical to physical address translation isunit. Logical to physical address translation is
taken care by the Operating System.taken care by the Operating System.
Memory AllocationMemory Allocation
Memory Allocation
Contiguous Allocation Non-Contiguous Allocation
Single-partition systems Multiple-partition systems
Fixed-Sized Partitions Variable Sized Partitions
Equal-Sized Unequal-Size
PagingPaging
 In a paged system, logical memory is dividedIn a paged system, logical memory is divided
into a number of fixed sizes ‘chunks’ calledinto a number of fixed sizes ‘chunks’ called
pagespages..
 The physical memory is also predivided intoThe physical memory is also predivided into
same fixed sized blocks (as is the size of pages)same fixed sized blocks (as is the size of pages)
calledcalled page framespage frames..
 The page sizes (also the frame sizes) areThe page sizes (also the frame sizes) are
always powers of 2, and vary between 512 bytesalways powers of 2, and vary between 512 bytes
to 8192 bytes per page. The reason behind thisto 8192 bytes per page. The reason behind this
is implementation of paging mechanism usingis implementation of paging mechanism using
page number and page offset.page number and page offset.
Paging SystemPaging System
Pages
Page0
Page1
Page2
Page3
Page4
1
3
6
4
2
0
1
2
3
4
Page0
Page4
Page1
Page3
Page2
1
2
3
4
5
6
Frames0
Logical Memory
PageNo. FrameNo
PageTable
Physical Memory
Page AllocationPage Allocation
 In variable sized partitioning of memory every time whenIn variable sized partitioning of memory every time when
a process of sizea process of size nn is to be loaded, it is important tois to be loaded, it is important to
know the best location from the list of available/freeknow the best location from the list of available/free
holes. This dynamic storage allocation is necessary toholes. This dynamic storage allocation is necessary to
increase efficiency and throughput of system. Mostincrease efficiency and throughput of system. Most
commonly used strategies to make such selection are:commonly used strategies to make such selection are:
 Best-fit Policy:Best-fit Policy: Allocating the hole in which theAllocating the hole in which the
process fits most “tightly” i.e., the difference between theprocess fits most “tightly” i.e., the difference between the
hole size and the process size is the minimum one.hole size and the process size is the minimum one.
 First-fit Policy:First-fit Policy: Allocating the first available holeAllocating the first available hole
(according to memory order), which is big enough to(according to memory order), which is big enough to
accommodate the new process.accommodate the new process.
 Worst-fit Policy:Worst-fit Policy: Allocating the largest hole that willAllocating the largest hole that will
leave maximum amount of unused space i.e., leftoverleave maximum amount of unused space i.e., leftover
space is maximum after allocation.space is maximum after allocation.
 Now, question arises which strategy is likely toNow, question arises which strategy is likely to
be used?be used?
 In practice, best-fit and first-fit are better thanIn practice, best-fit and first-fit are better than
worst-fit. Both these are efficient in terms of timeworst-fit. Both these are efficient in terms of time
and storage requirement.and storage requirement.
 Best-fit minimize the leftover space, createBest-fit minimize the leftover space, create
smallest hole that could be rarely used.smallest hole that could be rarely used.
 First-fit on the other hand requires leastFirst-fit on the other hand requires least
overheads in its implementation because of itsoverheads in its implementation because of its
simplicity.simplicity.
 Possibly worst-fit also sometimes leaves largePossibly worst-fit also sometimes leaves large
holes that could further be used toholes that could further be used to
accommodate other processes. Thus all theseaccommodate other processes. Thus all these
policies have their own merits and demerits.policies have their own merits and demerits.
Direct MappingDirect Mapping
Processor
(Running
Program)
P d
f
f d
Virtual Address Physical Address
P
Physical Memory
PageTableVA → PA
SegmentationSegmentation
 Segmentation presents an alternative schemeSegmentation presents an alternative scheme
for memory management.for memory management.
 This schemeThis scheme divides the logical address spacedivides the logical address space
into variable length chunks, called segments,into variable length chunks, called segments,
with no proper ordering among them. Eachwith no proper ordering among them. Each
segment has a name and a length. Forsegment has a name and a length. For
simplicity, segments are referred by a segmentsimplicity, segments are referred by a segment
number, rather than by a name.number, rather than by a name.
 Thus, the logical addresses are expressed as aThus, the logical addresses are expressed as a
pair of segment number and offset withinpair of segment number and offset within
segment.segment.
 It allows a program to be broken down intoIt allows a program to be broken down into
logical parts according to the user view oflogical parts according to the user view of
the memory, which is then mapped intothe memory, which is then mapped into
physical memory.physical memory.
 Though logical addresses are two-Though logical addresses are two-
dimensional but actual physical addressesdimensional but actual physical addresses
are still one-dimensional array of bytesare still one-dimensional array of bytes
only.only.
Address TranslationAddress Translation
Segment Table
Physical Memory
Yes
S d
Limit L BaseB
B+d+d<L
S
Physical AddressNo
Trap/ Error
dProcessor
Principle of OperationPrinciple of Operation
Segment 0
Segment 1
Segment 2
Segment 3
Segment 4
Limit Base
1000 1500
500 5000
400 3000
1000 4000
1100 6000
1
2
3
4
Segment Table
Segment 0
Segment 2
Segment 3
Segment 1
Segment 4
0
1500
2500
3000
3400
4000
5000
5500
6000
7100

More Related Content

What's hot

Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory managementrprajat007
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.Ravi Kumar Patel
 
Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structuresMukesh Chinta
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-SystemsVenkata Sreeram
 
Deadlock Avoidance - OS
Deadlock Avoidance - OSDeadlock Avoidance - OS
Deadlock Avoidance - OSMsAnita2
 
Chapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage SystemsChapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage SystemsWayne Jones Jnr
 
Operating System-Ch8 memory management
Operating System-Ch8 memory managementOperating System-Ch8 memory management
Operating System-Ch8 memory managementSyaiful Ahdan
 
contiguous memory allocation.pptx
contiguous memory allocation.pptxcontiguous memory allocation.pptx
contiguous memory allocation.pptxRajapriya82
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process ConceptsMukesh Chinta
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systemsvampugani
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentationusmankiyani1
 

What's hot (20)

Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
 
File system structure
File system structureFile system structure
File system structure
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
 
Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structures
 
File allocation methods (1)
File allocation methods (1)File allocation methods (1)
File allocation methods (1)
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Deadlock Avoidance - OS
Deadlock Avoidance - OSDeadlock Avoidance - OS
Deadlock Avoidance - OS
 
Chapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage SystemsChapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage Systems
 
Operating System-Ch8 memory management
Operating System-Ch8 memory managementOperating System-Ch8 memory management
Operating System-Ch8 memory management
 
contiguous memory allocation.pptx
contiguous memory allocation.pptxcontiguous memory allocation.pptx
contiguous memory allocation.pptx
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systems
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Distributed Operating System_1
Distributed Operating System_1Distributed Operating System_1
Distributed Operating System_1
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentation
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
 

Similar to Memory Management in OS

Basics of Operating System
Basics of Operating SystemBasics of Operating System
Basics of Operating SystemSoumit Ghosh
 
Introduction to Operating System (Important Notes)
Introduction to Operating System (Important Notes)Introduction to Operating System (Important Notes)
Introduction to Operating System (Important Notes)Gaurav Kakade
 
Operating systems types, spooling and buffering
Operating systems types, spooling and bufferingOperating systems types, spooling and buffering
Operating systems types, spooling and bufferingAyush Jain
 
services and system calls of operating system
services and system calls of operating system services and system calls of operating system
services and system calls of operating system Saurabh Soni
 
Os rtos.ppt
Os rtos.pptOs rtos.ppt
Os rtos.pptrahul km
 
Basic operating systems in computer and it's uses
Basic operating systems in computer and it's usesBasic operating systems in computer and it's uses
Basic operating systems in computer and it's usesSurya Vishnuram
 
Operating system (OS) itself is a process, what approaches are there.pdf
Operating system (OS) itself is a process, what approaches are there.pdfOperating system (OS) itself is a process, what approaches are there.pdf
Operating system (OS) itself is a process, what approaches are there.pdfJUSTSTYLISH3B2MOHALI
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memoryvampugani
 

Similar to Memory Management in OS (20)

Basics of Operating System
Basics of Operating SystemBasics of Operating System
Basics of Operating System
 
OS ppt.pdf
OS ppt.pdfOS ppt.pdf
OS ppt.pdf
 
Introduction to Operating System (Important Notes)
Introduction to Operating System (Important Notes)Introduction to Operating System (Important Notes)
Introduction to Operating System (Important Notes)
 
Operating systems types, spooling and buffering
Operating systems types, spooling and bufferingOperating systems types, spooling and buffering
Operating systems types, spooling and buffering
 
1.introduction
1.introduction1.introduction
1.introduction
 
1.Introduction
1.Introduction1.Introduction
1.Introduction
 
services and system calls of operating system
services and system calls of operating system services and system calls of operating system
services and system calls of operating system
 
Spr ch-01
Spr ch-01Spr ch-01
Spr ch-01
 
Os rtos.ppt
Os rtos.pptOs rtos.ppt
Os rtos.ppt
 
Operating system
Operating systemOperating system
Operating system
 
Michael snowhite1
Michael snowhite1Michael snowhite1
Michael snowhite1
 
Clifford sugerman
Clifford sugermanClifford sugerman
Clifford sugerman
 
Basic operating systems in computer and it's uses
Basic operating systems in computer and it's usesBasic operating systems in computer and it's uses
Basic operating systems in computer and it's uses
 
Operating system (OS) itself is a process, what approaches are there.pdf
Operating system (OS) itself is a process, what approaches are there.pdfOperating system (OS) itself is a process, what approaches are there.pdf
Operating system (OS) itself is a process, what approaches are there.pdf
 
Os by nishant raghav
Os by nishant raghavOs by nishant raghav
Os by nishant raghav
 
os mod1 notes
 os mod1 notes os mod1 notes
os mod1 notes
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
100-E
100-E100-E
100-E
 
Operating system
Operating systemOperating system
Operating system
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 

More from vampugani

Social media presentation
Social media presentationSocial media presentation
Social media presentationvampugani
 
Creating Quick Response(QR) Codes for the OER
Creating Quick Response(QR) Codes for the OERCreating Quick Response(QR) Codes for the OER
Creating Quick Response(QR) Codes for the OERvampugani
 
Arithmetic Computation using 2's Complement Notation
Arithmetic Computation using 2's Complement NotationArithmetic Computation using 2's Complement Notation
Arithmetic Computation using 2's Complement Notationvampugani
 
Post Graduate Diploma in Computer Applications (PGDCA)
Post Graduate Diploma in Computer Applications (PGDCA)Post Graduate Diploma in Computer Applications (PGDCA)
Post Graduate Diploma in Computer Applications (PGDCA)vampugani
 
Overview of Distributed Systems
Overview of Distributed SystemsOverview of Distributed Systems
Overview of Distributed Systemsvampugani
 
Protection and Security in Operating Systems
Protection and Security in Operating SystemsProtection and Security in Operating Systems
Protection and Security in Operating Systemsvampugani
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Schedulingvampugani
 
Introduction to OS
Introduction to OSIntroduction to OS
Introduction to OSvampugani
 
Operating Systems
Operating SystemsOperating Systems
Operating Systemsvampugani
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systemsvampugani
 
Multiprocessor Systems
Multiprocessor SystemsMultiprocessor Systems
Multiprocessor Systemsvampugani
 
Strings in c
Strings in cStrings in c
Strings in cvampugani
 
Control statements and functions in c
Control statements and functions in cControl statements and functions in c
Control statements and functions in cvampugani
 
Introduction to C Programming
Introduction to C Programming Introduction to C Programming
Introduction to C Programming vampugani
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I vampugani
 

More from vampugani (17)

Social media presentation
Social media presentationSocial media presentation
Social media presentation
 
Creating Quick Response(QR) Codes for the OER
Creating Quick Response(QR) Codes for the OERCreating Quick Response(QR) Codes for the OER
Creating Quick Response(QR) Codes for the OER
 
Arithmetic Computation using 2's Complement Notation
Arithmetic Computation using 2's Complement NotationArithmetic Computation using 2's Complement Notation
Arithmetic Computation using 2's Complement Notation
 
Post Graduate Diploma in Computer Applications (PGDCA)
Post Graduate Diploma in Computer Applications (PGDCA)Post Graduate Diploma in Computer Applications (PGDCA)
Post Graduate Diploma in Computer Applications (PGDCA)
 
Overview of Distributed Systems
Overview of Distributed SystemsOverview of Distributed Systems
Overview of Distributed Systems
 
Protection and Security in Operating Systems
Protection and Security in Operating SystemsProtection and Security in Operating Systems
Protection and Security in Operating Systems
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
Processes
ProcessesProcesses
Processes
 
Introduction to OS
Introduction to OSIntroduction to OS
Introduction to OS
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systems
 
Multiprocessor Systems
Multiprocessor SystemsMultiprocessor Systems
Multiprocessor Systems
 
Strings in c
Strings in cStrings in c
Strings in c
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Control statements and functions in c
Control statements and functions in cControl statements and functions in c
Control statements and functions in c
 
Introduction to C Programming
Introduction to C Programming Introduction to C Programming
Introduction to C Programming
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I
 

Recently uploaded

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 

Recently uploaded (20)

YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 

Memory Management in OS

  • 1. Memory Management inMemory Management in Operating SystemsOperating Systems V.V. SubrahmanyamV.V. Subrahmanyam SOCIS, IGNOUSOCIS, IGNOU Date: 31Date: 31stst March, 2008March, 2008 Time: 19-00 to 19-45Time: 19-00 to 19-45
  • 2. MemoryMemory  Memory is central to the operation of a modernMemory is central to the operation of a modern computer system.computer system.  Memory is a large array of words or bytes, eachMemory is a large array of words or bytes, each location with its own address.location with its own address.  Interaction is achieved through a sequence ofInteraction is achieved through a sequence of reads/writes of specific memory address.reads/writes of specific memory address.  The CPU fetches the program from the hard diskThe CPU fetches the program from the hard disk and stores in the memory.and stores in the memory.  If a program is to be executed, it must beIf a program is to be executed, it must be mapped to absolute addresses and loaded intomapped to absolute addresses and loaded into memory.memory.
  • 3. Contd…Contd…  In a multiprogramming environment, in order toIn a multiprogramming environment, in order to improve both the CPU utilisation and the speedimprove both the CPU utilisation and the speed of the computer’s response, several processesof the computer’s response, several processes must be kept in memory.must be kept in memory.  There are many different algorithms dependingThere are many different algorithms depending on the particular situation to manage theon the particular situation to manage the memory.memory.  Selection of a memory management scheme forSelection of a memory management scheme for a specific system depends upon many factors,a specific system depends upon many factors, but especially upon the hardware design of thebut especially upon the hardware design of the system.system.  Each algorithm requires its own hardwareEach algorithm requires its own hardware support.support.
  • 4. Memory Management –Memory Management – Responsibilities of OSResponsibilities of OS  Keep track of which parts of memory areKeep track of which parts of memory are currently being used and by whom.currently being used and by whom.  Decide which processes are to be loadedDecide which processes are to be loaded into memory when memory spaceinto memory when memory space becomes available.becomes available.  Allocate and deallocate memory space asAllocate and deallocate memory space as needed.needed.
  • 5. Contd…Contd…  In the multiprogramming environmentIn the multiprogramming environment operating system dynamically allocatesoperating system dynamically allocates memory to multiple processes.memory to multiple processes.  Thus memory plays a significant role inThus memory plays a significant role in the important aspects of computer systemthe important aspects of computer system like performance, S/W support, reliabilitylike performance, S/W support, reliability and stability.and stability.
  • 6. OverlaysOverlays  In idealistic situation, the entire program and itsIn idealistic situation, the entire program and its related data is loaded in physical memory forrelated data is loaded in physical memory for execution.execution.  But what if process is larger than the amount ofBut what if process is larger than the amount of memory allocated to it?memory allocated to it?  We can overcome this problem by adopting aWe can overcome this problem by adopting a technique called astechnique called as OverlaysOverlays. Like dynamic. Like dynamic loading, overlays can also be implemented byloading, overlays can also be implemented by users without OS support.users without OS support.
  • 7.  The entire program or application is divided intoThe entire program or application is divided into instructions and data sets such that when oneinstructions and data sets such that when one instruction set is needed it is loaded in memoryinstruction set is needed it is loaded in memory and after its execution is over, the space isand after its execution is over, the space is released.released.  As and when requirement for other instructionAs and when requirement for other instruction arises it is loaded into space that was releasedarises it is loaded into space that was released previously by the instructions that are no longerpreviously by the instructions that are no longer needed.needed.  Such instructions can be called as overlays,Such instructions can be called as overlays, which are loaded and unloaded by the program.which are loaded and unloaded by the program.
  • 8.  DefinitionDefinition: An overlay is a part of an: An overlay is a part of an application, which has been loaded at sameapplication, which has been loaded at same origin where previously some other part (s) oforigin where previously some other part (s) of the program was residing.the program was residing.  A program based on overlay scheme mainlyA program based on overlay scheme mainly consists of following:consists of following:  A “root” piece which is always memory residentA “root” piece which is always memory resident  Set of overlays.Set of overlays.  Overlay gives the program a way to extendOverlay gives the program a way to extend limited main storage. An important aspectlimited main storage. An important aspect related to overlays identification in program isrelated to overlays identification in program is concept of mutual exclusion i.e., routines whichconcept of mutual exclusion i.e., routines which do not invoke each other and are not loaded indo not invoke each other and are not loaded in memory simultaneously.memory simultaneously.
  • 9. Example of OverlayExample of Overlay Read ( ) Function1 ( ) Function2 ( ) Display ( ) Read ( ) Display ( ) Function2 ( )Function1() 20 K 20K Read( ) Read ( ) 50K Function1( ) Function 1( ) Function 2( ) 70K Function 2( ) Overlay A 40K Display ( ) Overlay B 40K Display ( ) (50K) (70K) Without Overlay (180K) With Overlay (Maximum.130K)
  • 10. Limitations of OverlaysLimitations of Overlays Overlays scheme suffers from following limitations:Overlays scheme suffers from following limitations:  Require careful and time-consuming planning.Require careful and time-consuming planning.  Programmer is responsible for organizingProgrammer is responsible for organizing overlay structure of program with the help of fileoverlay structure of program with the help of file structures etc. and also to ensure that piece ofstructures etc. and also to ensure that piece of code is already loaded when it is called.code is already loaded when it is called.  Operating System provides the facility to loadOperating System provides the facility to load files into overlay region.files into overlay region.
  • 11. SwappingSwapping  Swapping is an approach for memorySwapping is an approach for memory management by bringing each process inmanagement by bringing each process in entirety, running it and then putting it back on theentirety, running it and then putting it back on the disk, so that another program may be loadeddisk, so that another program may be loaded into that space.into that space.  Swapping is a technique that lets you use a diskSwapping is a technique that lets you use a disk file as an extension of memory.file as an extension of memory.  Lower priority user processes are swapped toLower priority user processes are swapped to backing store (disk) when they are waiting forbacking store (disk) when they are waiting for I/O or some other event like arrival of higherI/O or some other event like arrival of higher priority processes. This ispriority processes. This is Rollout SwappingRollout Swapping..  Swapping the process back into store whenSwapping the process back into store when some event occurs or when needed (may be in asome event occurs or when needed (may be in a different partition) is known asdifferent partition) is known as Roll-in swappingRoll-in swapping..
  • 13. Benefits of SwappingBenefits of Swapping  Allows higher degree of multiprogramming.Allows higher degree of multiprogramming.  Allows dynamic relocation, i.e., if addressAllows dynamic relocation, i.e., if address binding at execution time is being used we canbinding at execution time is being used we can swap in different location else in case of compileswap in different location else in case of compile and load time bindings processes have to beand load time bindings processes have to be moved to same location only.moved to same location only.  Better memory utilisation.Better memory utilisation.  Less wastage of CPU time on compaction, andLess wastage of CPU time on compaction, and  Can easily be applied on priority-basedCan easily be applied on priority-based scheduling algorithms to improve performance.scheduling algorithms to improve performance.
  • 14. LimitationsLimitations  Entire program must be resident in storeEntire program must be resident in store when it is executing.when it is executing.  Also processes with changing memoryAlso processes with changing memory requirements will need to issue systemrequirements will need to issue system calls for requesting and releasing memory.calls for requesting and releasing memory.  It is necessary to know exactly how muchIt is necessary to know exactly how much memory a user process is using and alsomemory a user process is using and also that it is blocked or waiting for I/O.that it is blocked or waiting for I/O.
  • 15. Logical and Physical AddressLogical and Physical Address SpaceSpace  The computer interacts via logical and physicalThe computer interacts via logical and physical addressing to map memory.addressing to map memory.  Logical address is the one that is generated byLogical address is the one that is generated by CPU, also referred to as virtual address. TheCPU, also referred to as virtual address. The program perceives this address space.program perceives this address space.  Physical address is the actual addressPhysical address is the actual address understood by computer hardware i.e., memoryunderstood by computer hardware i.e., memory unit. Logical to physical address translation isunit. Logical to physical address translation is taken care by the Operating System.taken care by the Operating System.
  • 16. Memory AllocationMemory Allocation Memory Allocation Contiguous Allocation Non-Contiguous Allocation Single-partition systems Multiple-partition systems Fixed-Sized Partitions Variable Sized Partitions Equal-Sized Unequal-Size
  • 17. PagingPaging  In a paged system, logical memory is dividedIn a paged system, logical memory is divided into a number of fixed sizes ‘chunks’ calledinto a number of fixed sizes ‘chunks’ called pagespages..  The physical memory is also predivided intoThe physical memory is also predivided into same fixed sized blocks (as is the size of pages)same fixed sized blocks (as is the size of pages) calledcalled page framespage frames..  The page sizes (also the frame sizes) areThe page sizes (also the frame sizes) are always powers of 2, and vary between 512 bytesalways powers of 2, and vary between 512 bytes to 8192 bytes per page. The reason behind thisto 8192 bytes per page. The reason behind this is implementation of paging mechanism usingis implementation of paging mechanism using page number and page offset.page number and page offset.
  • 19. Page AllocationPage Allocation  In variable sized partitioning of memory every time whenIn variable sized partitioning of memory every time when a process of sizea process of size nn is to be loaded, it is important tois to be loaded, it is important to know the best location from the list of available/freeknow the best location from the list of available/free holes. This dynamic storage allocation is necessary toholes. This dynamic storage allocation is necessary to increase efficiency and throughput of system. Mostincrease efficiency and throughput of system. Most commonly used strategies to make such selection are:commonly used strategies to make such selection are:  Best-fit Policy:Best-fit Policy: Allocating the hole in which theAllocating the hole in which the process fits most “tightly” i.e., the difference between theprocess fits most “tightly” i.e., the difference between the hole size and the process size is the minimum one.hole size and the process size is the minimum one.  First-fit Policy:First-fit Policy: Allocating the first available holeAllocating the first available hole (according to memory order), which is big enough to(according to memory order), which is big enough to accommodate the new process.accommodate the new process.  Worst-fit Policy:Worst-fit Policy: Allocating the largest hole that willAllocating the largest hole that will leave maximum amount of unused space i.e., leftoverleave maximum amount of unused space i.e., leftover space is maximum after allocation.space is maximum after allocation.
  • 20.  Now, question arises which strategy is likely toNow, question arises which strategy is likely to be used?be used?  In practice, best-fit and first-fit are better thanIn practice, best-fit and first-fit are better than worst-fit. Both these are efficient in terms of timeworst-fit. Both these are efficient in terms of time and storage requirement.and storage requirement.  Best-fit minimize the leftover space, createBest-fit minimize the leftover space, create smallest hole that could be rarely used.smallest hole that could be rarely used.  First-fit on the other hand requires leastFirst-fit on the other hand requires least overheads in its implementation because of itsoverheads in its implementation because of its simplicity.simplicity.  Possibly worst-fit also sometimes leaves largePossibly worst-fit also sometimes leaves large holes that could further be used toholes that could further be used to accommodate other processes. Thus all theseaccommodate other processes. Thus all these policies have their own merits and demerits.policies have their own merits and demerits.
  • 21. Direct MappingDirect Mapping Processor (Running Program) P d f f d Virtual Address Physical Address P Physical Memory PageTableVA → PA
  • 22. SegmentationSegmentation  Segmentation presents an alternative schemeSegmentation presents an alternative scheme for memory management.for memory management.  This schemeThis scheme divides the logical address spacedivides the logical address space into variable length chunks, called segments,into variable length chunks, called segments, with no proper ordering among them. Eachwith no proper ordering among them. Each segment has a name and a length. Forsegment has a name and a length. For simplicity, segments are referred by a segmentsimplicity, segments are referred by a segment number, rather than by a name.number, rather than by a name.  Thus, the logical addresses are expressed as aThus, the logical addresses are expressed as a pair of segment number and offset withinpair of segment number and offset within segment.segment.
  • 23.  It allows a program to be broken down intoIt allows a program to be broken down into logical parts according to the user view oflogical parts according to the user view of the memory, which is then mapped intothe memory, which is then mapped into physical memory.physical memory.  Though logical addresses are two-Though logical addresses are two- dimensional but actual physical addressesdimensional but actual physical addresses are still one-dimensional array of bytesare still one-dimensional array of bytes only.only.
  • 24. Address TranslationAddress Translation Segment Table Physical Memory Yes S d Limit L BaseB B+d+d<L S Physical AddressNo Trap/ Error dProcessor
  • 25. Principle of OperationPrinciple of Operation Segment 0 Segment 1 Segment 2 Segment 3 Segment 4 Limit Base 1000 1500 500 5000 400 3000 1000 4000 1100 6000 1 2 3 4 Segment Table Segment 0 Segment 2 Segment 3 Segment 1 Segment 4 0 1500 2500 3000 3400 4000 5000 5500 6000 7100