SlideShare une entreprise Scribd logo
MEMORY
MANAGEMENT
memory management
 In a multiprogramming system, in order to
share the processor, a number of processes
must be kept in memory.
 Memory management is achieved through
memory management algorithms.
 In order to be able to load programs at
anywhere in memory, the compiler must
generate relocatable object code.
 Also we must make it sure that a program in
memory, addresses only its own area, and no
other program’s area.
1
 Memory Allocation
Single Partition Allocation
In this scheme Operating system is
residing in low memory and user processes
are executing in higher memory.
Advantages
It is simple.
It is easy to understand and use.
Disadvantages
It leads to poor utilization of processor and
memory.
Users job is limited to the size of available
memory.
2
Multiple-partition Allocation
 One of the simplest methods for allocating
memory is to divide memory into several
fixed sized partitions.
 There are two variations of this.
 Fixed Equal-size Partitions
 Fixed Variable Size Partitions
3
Fixed Equal-size Partitions
 It divides the main memory into equal number of fixed
sized partitions, operating system occupies some fixed
portion and remaining portion of main memory is
available for user processes. Advantages
 Any process whose size is less than or equal to the
partition size can be loaded into any available partition.
 It supports multiprogramming.
 Disadvantages
 If a program is too big to fit into a partition use overlay
technique.
 Memory use is inefficient, i.e., block of data loaded into
memory may be smaller than the partition. It is known as
internal fragmentation.
4
Fixed Variable Size Partitions
 By using fixed variable size partitions we can
overcome the disadvantages present in fixed
equal size partitioning
5
3.2 Variable Partitioning
 With fixed partitions we have to deal with the problem of
determining the number and sizes of partitions to
minimize internal and external fragmentation.
 If we use variable partitioning instead, then partition
sizes may vary dynamically.
 In the variable partitioning method, we keep a table
(linked list) indicating used/free areas in memory.
6
fragmentation
memory
OS
2K
6K Empty (6K)
12K empty
Empty (3K)
P2 (9K)
P1 (2K)
If a whole partition is
currently not being used,
then it is called an
external fragmentation.
If a partition is being
used by a process
requiring some
memory smaller than
the partition size, then
it is called an internal
fragmentation.
7
3.2 Variable Partitioning
 Initially, the whole memory is free and it is considered as
one large block.
 When a new process arrives, the OS searches for a
block of free memory large enough for that process.
 We keep the rest available (free) for the future
processes.
 If a block becomes free, then the OS tries to merge it
with its neighbors if they are also free.
8
3.2 Variable Partitioning
 There are three algorithms for searching the list of free
blocks for a specific amount of memory.
 First Fit
 Best Fit
 Worst Fit
9
first fit
 First Fit : Allocate the first free block that is
large enough for the new process.
 This is a fast algorithm.
10
first fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
Initial memory
mapping
11
first fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
P4 of 3KB
arrives
12
first fit
OS
P1 12 KB
P4 3 KB
<FREE> 7 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
P4 of 3KB
loaded here by
FIRST FIT
13
first fit
OS
P1 12 KB
P4 3 KB
<FREE> 7 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
P5 of 15KB
arrives
14
first fit
OS
P1 12 KB
P4 3 KB
<FREE> 7 KB
P2 20 KB
P5 15 KB
<FREE> 1 KB
P3 6 KB
<FREE> 4 KB
P5 of 15 KB
loaded here by
FIRST FIT
15
Best fit
 Best Fit : Allocate the smallest block among those that
are large enough for the new process.
 In this method, the OS has to search the entire list, or it
can keep it sorted and stop when it hits an entry which
has a size larger than the size of new process.
 This algorithm produces the smallest left over block.
 However, it requires more time for searching all the list
or sorting it
 If sorting is used, merging the area released when a
process terminates to neighboring free blocks, becomes
complicated.
16
best fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
Initial memory
mapping
17
best fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
P4 of 3KB
arrives
18
best fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
P4 3 KB
<FREE> 1 KB
P4 of 3KB
loaded here by
BEST FIT
19
best fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
P4 3 KB
<FREE> 1 KB
P5 of 15KB
arrives
20
best fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
P5 15 KB
<FREE> 1 KB
P3 6 KB
P4 3 KB
<FREE> 1 KB
P5 of 15 KB
loaded here by
BEST FIT
21
worst fit
 Worst Fit : Allocate the largest block among those that
are large enough for the new process.
 Again a search of the entire list or sorting it is needed.
 This algorithm produces the largest over block.
22
worst fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
Initial memory
mapping
23
worst fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
<FREE> 16 KB
P3 6 KB
<FREE> 4 KB
P4 of 3KB
arrives
24
worst fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
P4 3 KB
<FREE> 13 KB
P3 6 KB
<FREE> 4 KB
P4 of 3KB
Loaded here by
WORST FIT
25
worst fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
P4 3 KB
<FREE> 13 KB
P3 6 KB
<FREE> 4 KB
No place to load
P5 of 15K
26
worst fit
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
P4 3 KB
<FREE> 13 KB
P3 6 KB
<FREE> 4 KB
No place to load
P5 of 15K
Compaction is
needed !!
27
compaction
 Compaction is a method to overcome the external
fragmentation problem.
 All free blocks are brought together as one large block of
free space.
 Compaction requires dynamic relocation.
 Certainly, compaction has a cost and selection of an
optimal compaction strategy is difficult.
 One method for compaction is swapping out those
processes that are to be moved within the memory, and
swapping them into different memory locations
28
compaction
OS
P1 12 KB
<FREE> 10 KB
P2 20 KB
P4 3 KB
<FREE> 13 KB
P3 6 KB
<FREE> 4 KB
29
Memory
mapping before
compaction
compaction
OS
P1 12 KB
P2 20 KB
P4 3 KB
P3 6 KB
30
Swap out
P2
compaction
OS
P1 12 KB
P2 20 KB
P4 3 KB
P3 6 KB
Swap in
P2
Secondary
storage
31
compaction
OS
P1 12 KB
P2 20 KB
P4 3 KB
P3 6 KB
Swap out
P4
Secondary
storage
32
compaction
OS
P1 12 KB
P2 20 KB
P4 3 KB
P3 6 KB
Swap in
P4 with a
different
starting
address
Secondary
storage
33
compaction
OS
P1 12 KB
P2 20 KB
P4 3 KB
P3 6 KB
Swap out
P3
Secondary
storage
34
compaction
OS
P1 12 KB
P2 20 KB
P4 3 KB
P3 6 KB
Swap in
P3
Secondary
storage
35
compaction
OS
P1 12 KB
P2 20 KB
P4 3 KB
P3 6 KB
<FREE> 27 KB
Memory
mapping after
compaction
Now P5 of 15KB
can be loaded
here
36
compaction
OS
P1 12 KB
P2 20 KB
P4 3 KB
P3 6 KB
P5 12 KB
<FREE> 12 KB P5 of 15KB is
loaded
37
Fragmentation
 There are two types of fragmentation in OS which
are given as: Internal fragmentation, and External
fragmentation.
 Internal Fragmentation:
Internal fragmentation happens when the
memory is split into mounted sized blocks.
Whenever a method request for the memory, the
mounted sized block is allotted to the method.
just in case the memory allotted to the method is
somewhat larger than the memory requested,
then the distinction between allotted and
38
 External Fragmentation:
External fragmentation happens when there’s
a sufficient quantity of area within the memory
to satisfy the memory request of a method.
however the process’s memory request cannot
be fulfilled because the memory offered is
during a non-contiguous manner.
39
40
External fragmentation
Comparison
41
•Internal fragmentation happens when
the method or process is larger than
the memory.
•The solution of internal fragmentation
is best-fit.
•Internal fragmentation occurs when
memory is divided into fixed sized .
•The difference between memory
allocated and required space or
memory is called Internal
fragmentation.
•External fragmentation happens when
the method or process is removed.
block.
•Solution of external fragmentation is
compaction, paging and segmentation
partitions.
•External fragmentation occurs when
memory is divided into variable size
partitions based on the size of
processes.
•The unused spaces formed between
non-contiguous memory fragments are
too small to serve a new process, is
called External fragmentation .

Contenu connexe

Similaire à memory mgmt.ppt

Operating System
Operating SystemOperating System
Operating System
Subhasis Dash
 
conviction in operating system
conviction in operating systemconviction in operating system
conviction in operating system
ADITHYAM19
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
Rashmi Bhat
 
7. Memory management in operating system.ppt
7. Memory management in operating system.ppt7. Memory management in operating system.ppt
7. Memory management in operating system.ppt
imrank39199
 
Chapter 8 : Memory
Chapter 8 : MemoryChapter 8 : Memory
Chapter 8 : Memory
Amin Omi
 
Tuning Solr & Pipeline for Logs
Tuning Solr & Pipeline for LogsTuning Solr & Pipeline for Logs
Tuning Solr & Pipeline for Logs
Sematext Group, Inc.
 
Tuning Solr and its Pipeline for Logs: Presented by Rafał Kuć & Radu Gheorghe...
Tuning Solr and its Pipeline for Logs: Presented by Rafał Kuć & Radu Gheorghe...Tuning Solr and its Pipeline for Logs: Presented by Rafał Kuć & Radu Gheorghe...
Tuning Solr and its Pipeline for Logs: Presented by Rafał Kuć & Radu Gheorghe...
Lucidworks
 
Ch02 early system memory management
Ch02 early system  memory managementCh02 early system  memory management
Ch02 early system memory management
Jacob Cadeliña
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory Management
Ajit Nayak
 
os
osos
Memory fragmentation by ofor williams daniel
Memory fragmentation by ofor williams danielMemory fragmentation by ofor williams daniel
Memory fragmentation by ofor williams daniel
Ofor Williams
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
Raj Mohan
 
FAQ on Dedupe NetApp
FAQ on Dedupe NetAppFAQ on Dedupe NetApp
FAQ on Dedupe NetApp
Ashwin Pawar
 
Operating Systems - Memory Management
Operating Systems - Memory ManagementOperating Systems - Memory Management
Operating Systems - Memory Management
Damian T. Gordon
 
Memory comp
Memory compMemory comp
Memory comp
Mohansonale1
 
lecture 8 b main memory
lecture 8 b main memorylecture 8 b main memory
lecture 8 b main memory
ITNet
 
Mca admissions in india
Mca admissions in indiaMca admissions in india
Mca admissions in india
Edhole.com
 
DB ppt OS unit - 3.pdf
DB ppt OS unit - 3.pdfDB ppt OS unit - 3.pdf
DB ppt OS unit - 3.pdf
DBharathi8
 
Analysis of Allocation Algorithms in Memory Management
Analysis of Allocation Algorithms in Memory ManagementAnalysis of Allocation Algorithms in Memory Management
Analysis of Allocation Algorithms in Memory Management
ijtsrd
 
Understanding operating systems 5th ed ch02
Understanding operating systems 5th ed ch02Understanding operating systems 5th ed ch02
Understanding operating systems 5th ed ch02
BarrBoy
 

Similaire à memory mgmt.ppt (20)

Operating System
Operating SystemOperating System
Operating System
 
conviction in operating system
conviction in operating systemconviction in operating system
conviction in operating system
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
7. Memory management in operating system.ppt
7. Memory management in operating system.ppt7. Memory management in operating system.ppt
7. Memory management in operating system.ppt
 
Chapter 8 : Memory
Chapter 8 : MemoryChapter 8 : Memory
Chapter 8 : Memory
 
Tuning Solr & Pipeline for Logs
Tuning Solr & Pipeline for LogsTuning Solr & Pipeline for Logs
Tuning Solr & Pipeline for Logs
 
Tuning Solr and its Pipeline for Logs: Presented by Rafał Kuć & Radu Gheorghe...
Tuning Solr and its Pipeline for Logs: Presented by Rafał Kuć & Radu Gheorghe...Tuning Solr and its Pipeline for Logs: Presented by Rafał Kuć & Radu Gheorghe...
Tuning Solr and its Pipeline for Logs: Presented by Rafał Kuć & Radu Gheorghe...
 
Ch02 early system memory management
Ch02 early system  memory managementCh02 early system  memory management
Ch02 early system memory management
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory Management
 
os
osos
os
 
Memory fragmentation by ofor williams daniel
Memory fragmentation by ofor williams danielMemory fragmentation by ofor williams daniel
Memory fragmentation by ofor williams daniel
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
 
FAQ on Dedupe NetApp
FAQ on Dedupe NetAppFAQ on Dedupe NetApp
FAQ on Dedupe NetApp
 
Operating Systems - Memory Management
Operating Systems - Memory ManagementOperating Systems - Memory Management
Operating Systems - Memory Management
 
Memory comp
Memory compMemory comp
Memory comp
 
lecture 8 b main memory
lecture 8 b main memorylecture 8 b main memory
lecture 8 b main memory
 
Mca admissions in india
Mca admissions in indiaMca admissions in india
Mca admissions in india
 
DB ppt OS unit - 3.pdf
DB ppt OS unit - 3.pdfDB ppt OS unit - 3.pdf
DB ppt OS unit - 3.pdf
 
Analysis of Allocation Algorithms in Memory Management
Analysis of Allocation Algorithms in Memory ManagementAnalysis of Allocation Algorithms in Memory Management
Analysis of Allocation Algorithms in Memory Management
 
Understanding operating systems 5th ed ch02
Understanding operating systems 5th ed ch02Understanding operating systems 5th ed ch02
Understanding operating systems 5th ed ch02
 

Dernier

Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
bijceesjournal
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
riddhimaagrawal986
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1
PKavitha10
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Data Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptxData Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptx
ramrag33
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 

Dernier (20)

Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Data Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptxData Control Language.pptx Data Control Language.pptx
Data Control Language.pptx Data Control Language.pptx
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 

memory mgmt.ppt

  • 2. memory management  In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory.  Memory management is achieved through memory management algorithms.  In order to be able to load programs at anywhere in memory, the compiler must generate relocatable object code.  Also we must make it sure that a program in memory, addresses only its own area, and no other program’s area. 1
  • 3.  Memory Allocation Single Partition Allocation In this scheme Operating system is residing in low memory and user processes are executing in higher memory. Advantages It is simple. It is easy to understand and use. Disadvantages It leads to poor utilization of processor and memory. Users job is limited to the size of available memory. 2
  • 4. Multiple-partition Allocation  One of the simplest methods for allocating memory is to divide memory into several fixed sized partitions.  There are two variations of this.  Fixed Equal-size Partitions  Fixed Variable Size Partitions 3
  • 5. Fixed Equal-size Partitions  It divides the main memory into equal number of fixed sized partitions, operating system occupies some fixed portion and remaining portion of main memory is available for user processes. Advantages  Any process whose size is less than or equal to the partition size can be loaded into any available partition.  It supports multiprogramming.  Disadvantages  If a program is too big to fit into a partition use overlay technique.  Memory use is inefficient, i.e., block of data loaded into memory may be smaller than the partition. It is known as internal fragmentation. 4
  • 6. Fixed Variable Size Partitions  By using fixed variable size partitions we can overcome the disadvantages present in fixed equal size partitioning 5
  • 7. 3.2 Variable Partitioning  With fixed partitions we have to deal with the problem of determining the number and sizes of partitions to minimize internal and external fragmentation.  If we use variable partitioning instead, then partition sizes may vary dynamically.  In the variable partitioning method, we keep a table (linked list) indicating used/free areas in memory. 6
  • 8. fragmentation memory OS 2K 6K Empty (6K) 12K empty Empty (3K) P2 (9K) P1 (2K) If a whole partition is currently not being used, then it is called an external fragmentation. If a partition is being used by a process requiring some memory smaller than the partition size, then it is called an internal fragmentation. 7
  • 9. 3.2 Variable Partitioning  Initially, the whole memory is free and it is considered as one large block.  When a new process arrives, the OS searches for a block of free memory large enough for that process.  We keep the rest available (free) for the future processes.  If a block becomes free, then the OS tries to merge it with its neighbors if they are also free. 8
  • 10. 3.2 Variable Partitioning  There are three algorithms for searching the list of free blocks for a specific amount of memory.  First Fit  Best Fit  Worst Fit 9
  • 11. first fit  First Fit : Allocate the first free block that is large enough for the new process.  This is a fast algorithm. 10
  • 12. first fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping 11
  • 13. first fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB P4 of 3KB arrives 12
  • 14. first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB P4 of 3KB loaded here by FIRST FIT 13
  • 15. first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB P5 of 15KB arrives 14
  • 16. first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB P5 15 KB <FREE> 1 KB P3 6 KB <FREE> 4 KB P5 of 15 KB loaded here by FIRST FIT 15
  • 17. Best fit  Best Fit : Allocate the smallest block among those that are large enough for the new process.  In this method, the OS has to search the entire list, or it can keep it sorted and stop when it hits an entry which has a size larger than the size of new process.  This algorithm produces the smallest left over block.  However, it requires more time for searching all the list or sorting it  If sorting is used, merging the area released when a process terminates to neighboring free blocks, becomes complicated. 16
  • 18. best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping 17
  • 19. best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB P4 of 3KB arrives 18
  • 20. best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB P4 3 KB <FREE> 1 KB P4 of 3KB loaded here by BEST FIT 19
  • 21. best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB P4 3 KB <FREE> 1 KB P5 of 15KB arrives 20
  • 22. best fit OS P1 12 KB <FREE> 10 KB P2 20 KB P5 15 KB <FREE> 1 KB P3 6 KB P4 3 KB <FREE> 1 KB P5 of 15 KB loaded here by BEST FIT 21
  • 23. worst fit  Worst Fit : Allocate the largest block among those that are large enough for the new process.  Again a search of the entire list or sorting it is needed.  This algorithm produces the largest over block. 22
  • 24. worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping 23
  • 25. worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB P4 of 3KB arrives 24
  • 26. worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB <FREE> 13 KB P3 6 KB <FREE> 4 KB P4 of 3KB Loaded here by WORST FIT 25
  • 27. worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB <FREE> 13 KB P3 6 KB <FREE> 4 KB No place to load P5 of 15K 26
  • 28. worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB <FREE> 13 KB P3 6 KB <FREE> 4 KB No place to load P5 of 15K Compaction is needed !! 27
  • 29. compaction  Compaction is a method to overcome the external fragmentation problem.  All free blocks are brought together as one large block of free space.  Compaction requires dynamic relocation.  Certainly, compaction has a cost and selection of an optimal compaction strategy is difficult.  One method for compaction is swapping out those processes that are to be moved within the memory, and swapping them into different memory locations 28
  • 30. compaction OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB <FREE> 13 KB P3 6 KB <FREE> 4 KB 29 Memory mapping before compaction
  • 31. compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB 30 Swap out P2
  • 32. compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Swap in P2 Secondary storage 31
  • 33. compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Swap out P4 Secondary storage 32
  • 34. compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Swap in P4 with a different starting address Secondary storage 33
  • 35. compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Swap out P3 Secondary storage 34
  • 36. compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Swap in P3 Secondary storage 35
  • 37. compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB <FREE> 27 KB Memory mapping after compaction Now P5 of 15KB can be loaded here 36
  • 38. compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB P5 12 KB <FREE> 12 KB P5 of 15KB is loaded 37
  • 39. Fragmentation  There are two types of fragmentation in OS which are given as: Internal fragmentation, and External fragmentation.  Internal Fragmentation: Internal fragmentation happens when the memory is split into mounted sized blocks. Whenever a method request for the memory, the mounted sized block is allotted to the method. just in case the memory allotted to the method is somewhat larger than the memory requested, then the distinction between allotted and 38
  • 40.  External Fragmentation: External fragmentation happens when there’s a sufficient quantity of area within the memory to satisfy the memory request of a method. however the process’s memory request cannot be fulfilled because the memory offered is during a non-contiguous manner. 39
  • 42. Comparison 41 •Internal fragmentation happens when the method or process is larger than the memory. •The solution of internal fragmentation is best-fit. •Internal fragmentation occurs when memory is divided into fixed sized . •The difference between memory allocated and required space or memory is called Internal fragmentation. •External fragmentation happens when the method or process is removed. block. •Solution of external fragmentation is compaction, paging and segmentation partitions. •External fragmentation occurs when memory is divided into variable size partitions based on the size of processes. •The unused spaces formed between non-contiguous memory fragments are too small to serve a new process, is called External fragmentation .