SlideShare a Scribd company logo
Memory Management
Dr. Saeed Arif
The need for memory
management
• Memory is cheap today, and getting
cheaper
– But applications are demanding more and
more memory, there is never enough!
• Memory Management, involves allocation
and swapping blocks of data to/from
secondary storage.
• Memory I/O is slow compared to a CPU
– The OS must cleverly time the swapping to
maximise the CPU’s efficiency
Addressing
Memory Management
Requirements
• Relocation
• Protection
• Sharing
Requirements: Relocation
• The programmer does not know where the
program will be placed in memory when it
is executed,
– it may be swapped to disk and return to main
memory at a different location (relocated)
• Memory references must be translated to
the actual physical memory address
Requirements: Protection
• Processes should not be able to reference
memory locations in another process
without permission
• Impossible to check absolute addresses at
compile time
• Must be checked at run time
Requirements: Sharing
• Allow several processes to access the
same portion of memory
• Better to allow each process access to the
same copy of the program rather than
have their own separate copy
Partitioning
• An early method of managing memory
– Pre-virtual memory
– Not used much now
• But, it will clarify the later discussion of
virtual memory if we look first at
partitioning
– Virtual Memory has evolved from the
partitioning methods
Types of Partitioning
• Fixed Partitioning
• Dynamic Partitioning
• Simple Paging
• Simple Segmentation
• Virtual Memory Paging
• Virtual Memory Segmentation
Fixed Partitioning
• Equal-size partitions
– Any process whose size is less than
or equal to the partition size can be
loaded into an available partition
• The operating system can swap a
process out of a partition
Fixed Partitioning Problems
• A program may not fit in a partition.
– The programmer must design the program
with overlays
• Main memory use is inefficient.
– Any program, no matter how small, occupies
an entire partition.
– This results in internal fragmentation.
Solution – Unequal Size
Partitions
• Lessens both problems
– but doesn’t solve completely
Placement Algorithm
• Equal-size
– Placement is trivial (no options)
• Unequal-size
– Can assign each process to the smallest
partition within which it will fit
– Queue for each partition
– Processes are assigned in such a way as to
minimize wasted memory within a partition
Fixed Partitioning
Remaining Problems with
Fixed Partitions
• The number of active processes is limited
by the system
– I.E limited by the pre-determined number of
partitions
• A large number of very small process will
not use the space efficiently
– In either fixed or variable length partition
methods
Dynamic Partitioning
• Partitions are of variable length and
number
• Process is allocated exactly as much
memory as required
Dynamic Partitioning
Example
• External Fragmentation
• Memory external to all
processes is fragmented
• Can resolve using
compaction
– OS moves processes so
that they are contiguous
– Time consuming and
wastes CPU
time(Relocation)
OS (8M)
P1
(20M)
P2
(14M)
P3
(18M)
Empty
(56M)
Empty (4M)
P4(8M)
Empty (6M)
P2
(14M)
Empty (6M)
Refer to Figure 7.4
Dynamic Partitioning
• Operating system must decide which free
block to allocate to a process
• Best-fit algorithm
– Chooses the block that is closest in size to the
request
• Worst performer overall
• Since smallest block is found for process, the
smallest amount of fragmentation is left
– Memory compaction must be done more often
Dynamic Partitioning
• First-fit algorithm
– Scans memory form the beginning and
chooses the first available block that is large
enough
– Fastest
Dynamic Partitioning
• Next-fit
– Scans memory from the location of the last
placement
– More often allocate a block of memory at the
end of memory where the largest block is
found
– The largest block of memory is broken up into
smaller blocks
– Compaction is required to obtain a large block
at the end of memory
Allocation
Buddy System
• Entire space available is treated as a
single block of 2U
• If a request of size s where 2U-1 < s <= 2U
– entire block is allocated
• Otherwise block is split into two equal
buddies
– Process continues until smallest block greater
than or equal to s is generated
Example of Buddy System
Relocation
• When program loaded into memory the
actual (absolute) memory locations are
determined
• A process may occupy different partitions
which means different absolute memory
locations during execution
– Swapping
– Compaction
Addresses
• Logical
– Reference to a memory location independent
of the current assignment of data to memory.
• Relative
– Address expressed as a location relative to
some known point.
• Physical or Absolute
– The absolute address or actual location in
main memory.
Protection and Relocation
partition 0
partition 1
partition 2
partition 3
0
2K
6K
8K
12K
physical memory
Offset(Relative) +
Logical address
P2’s base: 6K
base register
2K
<?
no
raise
protection fault
limit register
yes
Registers Used during
Execution
• Base register
– Starting address for the process
• Bounds(limit) register
– Ending location of the process
• These values are set when the process is
loaded or when the process is swapped in
Registers Used during
Execution
• The value of the base register is added to
a relative address to produce an absolute
address
• The resulting address is compared with
the value in the bounds register
• If the address is not within bounds, an
interrupt is generated to the operating
system
Paging
• Partition memory into small equal fixed-
size chunks and divide each process into
the same size chunks
• The chunks of a process are called pages
• The chunks of memory are called frames
Paging
• Operating system maintains a page table
for each process
– Contains the frame location for each page in
the process
– Memory address consist of a page number
and offset within the page
Processes and Frames
A.0
A.1
A.2
A.3
B.0
B.1
B.2
C.0
C.1
C.2
C.3
D.0
D.1
D.2
D.3
D.4
Page Table
Segmentation
• A program can be subdivided into
segments
– Segments may vary in length
– There is a maximum segment length
• Addressing consist of two parts
– a segment number and
– an offset
• Segmentation is similar to dynamic
partitioning
Virtual Memory Management
Key points in
Memory Management
1) A process may be broken up into pieces
that do not need to located contiguously
in main memory
2) Memory references are logical addresses
dynamically translated into physical
addresses at run time
– A process may be swapped in and out of main
memory occupying different regions at
different times during execution
Breakthrough in
Memory Management
• If both of those two characteristics are
present,
– then it is not necessary that all of the pages
or all of the segments of a process be in main
memory during execution.
• If the next instruction, and the next data
location are in memory then execution can
proceed
– at least for a time
Implications of
this new strategy
• More processes may be maintained in
main memory
– Only load in some of the pieces of each
process
– With so many processes in main memory, it is
very likely a process will be in the Ready state
at any particular time
• A process may be larger than all of main
memory
Support Needed for
Virtual Memory
• Hardware must support paging and
segmentation
• Operating system must be able to manage
the movement of pages and/or segments
between secondary memory and main
memory
Paging with virtual memory
• Solve the external fragmentation problem by using fixed sized units in
both physical and virtual memory
frame 0
frame 1
frame 2
frame Y
physical address space
…
page 0
page 1
page 2
page X
virtual address space
…
page 3

More Related Content

What's hot

Contiguous Memory Allocation-R.D.Sivakumar
Contiguous Memory Allocation-R.D.SivakumarContiguous Memory Allocation-R.D.Sivakumar
Contiguous Memory Allocation-R.D.Sivakumar
Sivakumar R D .
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
rprajat007
 
Memory Management
Memory ManagementMemory Management
Memory Management
DEDE IRYAWAN
 
Elements of cache design
Elements of cache designElements of cache design
Elements of cache design
Rohail Butt
 
Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating system
Prankit Mishra
 
Process management
Process managementProcess management
Process management
Birju Tank
 
Interleaved memory
Interleaved memoryInterleaved memory
Interleaved memory
ashishgy
 
Memory management
Memory managementMemory management
Memory management
cpjcollege
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
Johan Granados Montero
 
Notes on NUMA architecture
Notes on NUMA architectureNotes on NUMA architecture
Notes on NUMA architecture
Intel Software Brasil
 
Classical problem of synchronization
Classical problem of synchronizationClassical problem of synchronization
Classical problem of synchronizationShakshi Ranawat
 
Distributed Shared Memory Systems
Distributed Shared Memory SystemsDistributed Shared Memory Systems
Distributed Shared Memory Systems
Arush Nagpal
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
Khushboo Jain
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
vampugani
 
Virtual memory presentation
Virtual memory presentationVirtual memory presentation
Virtual memory presentation
Ranjeet Kumar
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
Nishant Joshi
 
Memory management
Memory managementMemory management
Memory management
Vishal Singh
 
Memory management ppt
Memory management pptMemory management ppt
Memory management ppt
ManishaJha43
 
Storage Structure in OS
Storage Structure in OSStorage Structure in OS
Storage Structure in OS
UniSoftCorner Pvt Ltd India.
 

What's hot (20)

Contiguous Memory Allocation-R.D.Sivakumar
Contiguous Memory Allocation-R.D.SivakumarContiguous Memory Allocation-R.D.Sivakumar
Contiguous Memory Allocation-R.D.Sivakumar
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Elements of cache design
Elements of cache designElements of cache design
Elements of cache design
 
Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating system
 
Process management
Process managementProcess management
Process management
 
Interleaved memory
Interleaved memoryInterleaved memory
Interleaved memory
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Memory management
Memory managementMemory management
Memory management
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 
Notes on NUMA architecture
Notes on NUMA architectureNotes on NUMA architecture
Notes on NUMA architecture
 
Classical problem of synchronization
Classical problem of synchronizationClassical problem of synchronization
Classical problem of synchronization
 
Distributed Shared Memory Systems
Distributed Shared Memory SystemsDistributed Shared Memory Systems
Distributed Shared Memory Systems
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Virtual memory presentation
Virtual memory presentationVirtual memory presentation
Virtual memory presentation
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
 
Memory management
Memory managementMemory management
Memory management
 
Memory management ppt
Memory management pptMemory management ppt
Memory management ppt
 
Storage Structure in OS
Storage Structure in OSStorage Structure in OS
Storage Structure in OS
 

Similar to Memory management1

07-MemoryManagement.ppt
07-MemoryManagement.ppt07-MemoryManagement.ppt
07-MemoryManagement.ppt
hello509579
 
Chapter07_ds.ppt
Chapter07_ds.pptChapter07_ds.ppt
Chapter07_ds.ppt
AvadhRakholiya3
 
Memory Management in Operating Systems for all
Memory Management in Operating Systems for allMemory Management in Operating Systems for all
Memory Management in Operating Systems for all
VSKAMCSPSGCT
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
Bitta_man
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
dilip kumar
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
Anwal Mirza
 
Lecture-7 Main Memroy.pptx
Lecture-7 Main Memroy.pptxLecture-7 Main Memroy.pptx
Lecture-7 Main Memroy.pptx
Amanuelmergia
 
Memory management
Memory managementMemory management
Memory management
PATELARCH
 
Ch8 main memory
Ch8   main memoryCh8   main memory
Ch8 main memory
Welly Dian Astika
 
PAGIN AND SEGMENTATION.docx
PAGIN AND SEGMENTATION.docxPAGIN AND SEGMENTATION.docx
PAGIN AND SEGMENTATION.docx
ImranBhatti58
 
Memory Management Strategies - II.pdf
Memory Management Strategies - II.pdfMemory Management Strategies - II.pdf
Memory Management Strategies - II.pdf
Harika Pudugosula
 
Memory Management.pdf
Memory Management.pdfMemory Management.pdf
Memory Management.pdf
SujanTimalsina5
 
Memory Management
Memory ManagementMemory Management
Memory Management
lavanya marichamy
 
Operating systems- Main Memory Management
Operating systems- Main Memory ManagementOperating systems- Main Memory Management
Operating systems- Main Memory Management
Chandrakant Divate
 
UNIT-2 OS.pptx
UNIT-2 OS.pptxUNIT-2 OS.pptx
UNIT-2 OS.pptx
ssusera387fd1
 
memory managment on computer science.ppt
memory managment on computer science.pptmemory managment on computer science.ppt
memory managment on computer science.ppt
footydigarse
 
CSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptxCSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptx
MadhuraK13
 
Os unit 3
Os unit 3Os unit 3
Os unit 3
SandhyaTatekalva
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OSC.U
 

Similar to Memory management1 (20)

07-MemoryManagement.ppt
07-MemoryManagement.ppt07-MemoryManagement.ppt
07-MemoryManagement.ppt
 
Chapter07_ds.ppt
Chapter07_ds.pptChapter07_ds.ppt
Chapter07_ds.ppt
 
Memory Management in Operating Systems for all
Memory Management in Operating Systems for allMemory Management in Operating Systems for all
Memory Management in Operating Systems for all
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
Lecture-7 Main Memroy.pptx
Lecture-7 Main Memroy.pptxLecture-7 Main Memroy.pptx
Lecture-7 Main Memroy.pptx
 
Memory management
Memory managementMemory management
Memory management
 
Ch8 main memory
Ch8   main memoryCh8   main memory
Ch8 main memory
 
PAGIN AND SEGMENTATION.docx
PAGIN AND SEGMENTATION.docxPAGIN AND SEGMENTATION.docx
PAGIN AND SEGMENTATION.docx
 
Memory Management Strategies - II.pdf
Memory Management Strategies - II.pdfMemory Management Strategies - II.pdf
Memory Management Strategies - II.pdf
 
Memory Management.pdf
Memory Management.pdfMemory Management.pdf
Memory Management.pdf
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Operating systems- Main Memory Management
Operating systems- Main Memory ManagementOperating systems- Main Memory Management
Operating systems- Main Memory Management
 
UNIT-2 OS.pptx
UNIT-2 OS.pptxUNIT-2 OS.pptx
UNIT-2 OS.pptx
 
memory managment on computer science.ppt
memory managment on computer science.pptmemory managment on computer science.ppt
memory managment on computer science.ppt
 
CSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptxCSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptx
 
Os unit 3
Os unit 3Os unit 3
Os unit 3
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OS
 

More from rizwanaabassi

Hci lecture set_03_00
Hci lecture set_03_00Hci lecture set_03_00
Hci lecture set_03_00rizwanaabassi
 
Subnetting a class_c_address
Subnetting a class_c_addressSubnetting a class_c_address
Subnetting a class_c_addressrizwanaabassi
 
Pesentation of formal
Pesentation of formalPesentation of formal
Pesentation of formalrizwanaabassi
 

More from rizwanaabassi (10)

Deadlocks2
Deadlocks2Deadlocks2
Deadlocks2
 
Io (2)
Io (2)Io (2)
Io (2)
 
Deadlocks1
Deadlocks1Deadlocks1
Deadlocks1
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Hci lecture set_03_00
Hci lecture set_03_00Hci lecture set_03_00
Hci lecture set_03_00
 
Hci lecture 01_00
Hci lecture 01_00Hci lecture 01_00
Hci lecture 01_00
 
Oslecture1
Oslecture1Oslecture1
Oslecture1
 
Data com lec1
Data com lec1Data com lec1
Data com lec1
 
Subnetting a class_c_address
Subnetting a class_c_addressSubnetting a class_c_address
Subnetting a class_c_address
 
Pesentation of formal
Pesentation of formalPesentation of formal
Pesentation of formal
 

Recently uploaded

By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 

Recently uploaded (20)

By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 

Memory management1

  • 2. The need for memory management • Memory is cheap today, and getting cheaper – But applications are demanding more and more memory, there is never enough! • Memory Management, involves allocation and swapping blocks of data to/from secondary storage. • Memory I/O is slow compared to a CPU – The OS must cleverly time the swapping to maximise the CPU’s efficiency
  • 5. Requirements: Relocation • The programmer does not know where the program will be placed in memory when it is executed, – it may be swapped to disk and return to main memory at a different location (relocated) • Memory references must be translated to the actual physical memory address
  • 6. Requirements: Protection • Processes should not be able to reference memory locations in another process without permission • Impossible to check absolute addresses at compile time • Must be checked at run time
  • 7. Requirements: Sharing • Allow several processes to access the same portion of memory • Better to allow each process access to the same copy of the program rather than have their own separate copy
  • 8. Partitioning • An early method of managing memory – Pre-virtual memory – Not used much now • But, it will clarify the later discussion of virtual memory if we look first at partitioning – Virtual Memory has evolved from the partitioning methods
  • 9. Types of Partitioning • Fixed Partitioning • Dynamic Partitioning • Simple Paging • Simple Segmentation • Virtual Memory Paging • Virtual Memory Segmentation
  • 10. Fixed Partitioning • Equal-size partitions – Any process whose size is less than or equal to the partition size can be loaded into an available partition • The operating system can swap a process out of a partition
  • 11. Fixed Partitioning Problems • A program may not fit in a partition. – The programmer must design the program with overlays • Main memory use is inefficient. – Any program, no matter how small, occupies an entire partition. – This results in internal fragmentation.
  • 12. Solution – Unequal Size Partitions • Lessens both problems – but doesn’t solve completely
  • 13. Placement Algorithm • Equal-size – Placement is trivial (no options) • Unequal-size – Can assign each process to the smallest partition within which it will fit – Queue for each partition – Processes are assigned in such a way as to minimize wasted memory within a partition
  • 15. Remaining Problems with Fixed Partitions • The number of active processes is limited by the system – I.E limited by the pre-determined number of partitions • A large number of very small process will not use the space efficiently – In either fixed or variable length partition methods
  • 16. Dynamic Partitioning • Partitions are of variable length and number • Process is allocated exactly as much memory as required
  • 17. Dynamic Partitioning Example • External Fragmentation • Memory external to all processes is fragmented • Can resolve using compaction – OS moves processes so that they are contiguous – Time consuming and wastes CPU time(Relocation) OS (8M) P1 (20M) P2 (14M) P3 (18M) Empty (56M) Empty (4M) P4(8M) Empty (6M) P2 (14M) Empty (6M) Refer to Figure 7.4
  • 18. Dynamic Partitioning • Operating system must decide which free block to allocate to a process • Best-fit algorithm – Chooses the block that is closest in size to the request • Worst performer overall • Since smallest block is found for process, the smallest amount of fragmentation is left – Memory compaction must be done more often
  • 19. Dynamic Partitioning • First-fit algorithm – Scans memory form the beginning and chooses the first available block that is large enough – Fastest
  • 20. Dynamic Partitioning • Next-fit – Scans memory from the location of the last placement – More often allocate a block of memory at the end of memory where the largest block is found – The largest block of memory is broken up into smaller blocks – Compaction is required to obtain a large block at the end of memory
  • 22. Buddy System • Entire space available is treated as a single block of 2U • If a request of size s where 2U-1 < s <= 2U – entire block is allocated • Otherwise block is split into two equal buddies – Process continues until smallest block greater than or equal to s is generated
  • 24. Relocation • When program loaded into memory the actual (absolute) memory locations are determined • A process may occupy different partitions which means different absolute memory locations during execution – Swapping – Compaction
  • 25. Addresses • Logical – Reference to a memory location independent of the current assignment of data to memory. • Relative – Address expressed as a location relative to some known point. • Physical or Absolute – The absolute address or actual location in main memory.
  • 26. Protection and Relocation partition 0 partition 1 partition 2 partition 3 0 2K 6K 8K 12K physical memory Offset(Relative) + Logical address P2’s base: 6K base register 2K <? no raise protection fault limit register yes
  • 27. Registers Used during Execution • Base register – Starting address for the process • Bounds(limit) register – Ending location of the process • These values are set when the process is loaded or when the process is swapped in
  • 28. Registers Used during Execution • The value of the base register is added to a relative address to produce an absolute address • The resulting address is compared with the value in the bounds register • If the address is not within bounds, an interrupt is generated to the operating system
  • 29. Paging • Partition memory into small equal fixed- size chunks and divide each process into the same size chunks • The chunks of a process are called pages • The chunks of memory are called frames
  • 30. Paging • Operating system maintains a page table for each process – Contains the frame location for each page in the process – Memory address consist of a page number and offset within the page
  • 33. Segmentation • A program can be subdivided into segments – Segments may vary in length – There is a maximum segment length • Addressing consist of two parts – a segment number and – an offset • Segmentation is similar to dynamic partitioning
  • 35. Key points in Memory Management 1) A process may be broken up into pieces that do not need to located contiguously in main memory 2) Memory references are logical addresses dynamically translated into physical addresses at run time – A process may be swapped in and out of main memory occupying different regions at different times during execution
  • 36. Breakthrough in Memory Management • If both of those two characteristics are present, – then it is not necessary that all of the pages or all of the segments of a process be in main memory during execution. • If the next instruction, and the next data location are in memory then execution can proceed – at least for a time
  • 37. Implications of this new strategy • More processes may be maintained in main memory – Only load in some of the pieces of each process – With so many processes in main memory, it is very likely a process will be in the Ready state at any particular time • A process may be larger than all of main memory
  • 38. Support Needed for Virtual Memory • Hardware must support paging and segmentation • Operating system must be able to manage the movement of pages and/or segments between secondary memory and main memory
  • 39. Paging with virtual memory • Solve the external fragmentation problem by using fixed sized units in both physical and virtual memory frame 0 frame 1 frame 2 frame Y physical address space … page 0 page 1 page 2 page X virtual address space … page 3

Editor's Notes

  1. in a uniprogramming system, main memory is divided into two parts: one part for the operating system (resident monitor, kernel) and one part for the program currently being executed. In a multiprogramming system, the “user” part of memory must be further subdivided to accommodate multiple processes.Emphasise that memory management is vital in a multiprogramming system. If only a few processes are in memory, then for much of the time all of the processes will be waitingfor I/O and the processor will be idle.Thus memory needs to be allocated to ensure a reasonable supply of ready processes to consume available processor time.
  2. This figure depicts a process image. Talk the students through this diagramAssume that the process image occupies a contiguous region of main memory. The OS needs to know the location of:process control information the execution stack, the entry point to begin execution of the program for this process. Because the operating system knows this information because it is managing memory and is responsible for bringing this process into main memory. However, the processor must deal with memory references within the program. Branch instructions contain an address to reference the instruction to be executed next. Data reference instructions contain the address of the byte or word of data referenced. Somehow, the processor hardware and operating system software must be able to translate the memory references found in the code of the program into actual physical memory addresses, reflecting the current location of the program in main memory.
  3. The following slides expandon these topics.
  4. Normally, a user process cannot access any portion of the operating system, neither program nor data. Usually a program in one process cannot branch to an instruction in another process or access the data area of another process. The processor must be able to abort such instructions at the point of execution.Note that the memory protection requirement must be satisfied by the processor (hardware) rather than the operating system (software) because the OS cannot anticipate all of the memory references that a program will make. It is only possible to assess the permissibility of a memory reference at the time of execution.Why is it a Bad Thing for one process to be able to read, or even write, to memory occupied by a different process?Why is it impossible to check absolute addresses at compile time (hint: see relocation)
  5. Any protection mechanism must have the flexibility to allow several processes to access the same portion of main memory. Processes that are cooperating on some task may need to share access to the same data structure.
  6. Don’t dwell on this slide – it is just an indication on the various approaches which will be covered in further detail in other slides
  7. Finish by mentioning tat fixed partitioning is almost unknown today
  8. Animated slideImagine a system with 64M RAMInitially, main memory is empty, except for the operating system Three processes are loaded in – leaving a ‘hole’ too small for any further processAt some point, none of the processes in memory is ready. The operating system swaps out process 2, Which leaves sufficient room to load a new process, process 4 – but that creates another holeLater, a point is reached at which none of the processes in main memory is ready, but process 2, in the Ready-Suspend state, is available. Because there is insufficient room in memory for process 2, the operating system swaps process 1 out and swaps process 2 back in leaving yet another holeExplain External Fragmentation and compaction – mention that compaction implies the capability of dynamic relocation
  9. Slide shows Fig 7.5 - an example memory configuration after a number of placement and swapping-out operations. The last block that was used was a 22-Mbyte block from which a 14-Mbyte partition was created. Figure 7.5b shows the difference between the best, first, and next-fit placement algorithms in satisfying a 16-Mbyte allocation request.Best-fit will search the entire list of available blocks and make use of the 18-Mbyte block, leaving a 2-Mbyte fragment.First-fit results in a 6-Mbyte fragment, and Next-fit results in a 20-Mbyte fragment.
  10. In a fixed partitioning scheme limits the number of active processes and may use space inefficiently if there is a poor match between available partition sizes and process sizes.A dynamic partitioning scheme is more complex to maintain and includes the overhead of compaction.An interesting compromise is the buddy system.
  11. Figure 7.6 gives an example using a 1-Mbyte initial block.The first request,A, is for 100 Kbytes, for which a 128K block is needed.The initial block is divided into two 512K buddies.The first of these is divided into two 256K buddies, and the first of these is divided into two 128K buddies, one of which is allocated to A.The next request,B, requires a 256K block. Such a block is already available and is allocated. The process continues with splitting and coalescing occurring as needed.Note that when E is released,two 128K buddies are coalesced into a 256K block, which is immediately coalesced with its buddy
  12. means that the address the program sees is different from the physical address of the data being stored in RAM.translation must be made from both Logical and Relative addresses to arrive at the Absolute address
  13. Animated slideSystem with a number of frames allocatedProcess A, stored on disk, consists of four pages. When it comes time to load this process, the operating system finds four free frames and loads the four pages of process A into the four frames.Process B, consisting of three pages, and process C, consisting of four pages, are subsequently loaded.Then process B is suspended and is swapped out of main memory. Later, all of the processes in main memory are blocked, and the operating system needs to bring in a new process, process D, which consists of five pages. The Operating System loads the pages into the available frames and updates the page table
  14. The difference with dynamic partitioning, is that with segmentation a program may occupy more than one partition, and these partitions need not be contiguous.Segmentation eliminates internal fragmentation but suffers from external fragmentation (as does dynamic partitioning)However, because a process is broken up into a number of smaller pieces, the external fragmentation should be less.A consequence of unequal-size segments is that there is no simple relationship between logical addresses and physical addresses. Analogous to paging, a simple segmentation scheme would make use of a segment table for each process and a list of free blocks of main memory. Each segment table entry would have to give the starting address in main memory of the corresponding segment. the length of the segment, to assure that invalid addresses are not used.When a process enters the Running state, the address of its segment table is loaded into a special register used by the memory management hardware.
  15. Two characteristics of paging and segmentation are the keys to this breakthrough in memory management:All memory references within a process are logical addresses that are dynamically translated into physical addresses at run time.A process may be swapped in and out of main memory occupying different regions of main memory at different times during the course of execution.2. A process may be broken up into a number of pieces (pages or segments) and these pieces need not be contiguously located in main memory during execution.The combination of dynamic run-time address translation and the use of a page or segment table permits this.
  16. If the piece (segment or page) that holds the next instruction to be fetched and the piece that holds the next data location to be accessed are in main memory, then execution may proceed (at least for a time).
  17. More processes may be maintained in main memory. Because we are only going to load some of the pieces of any particular process, there is room for more processes. This leads to more efficient utilization of the processor because it is more likely that at least one of the more numerous processes will be in a Ready state at any particular time.2. A process may be larger than all of main memory. Without the scheme a programmer must be acutely aware of how much memory is available. If the program being written is too large, the programmer must devise ways to structure the program into pieces that can be loaded separately in some sort of overlay strategy. With virtual memory based on paging or segmentation, that job is left to the operating system and the hardware. As far as the programmer is concerned, he or she is dealing with a huge memory, the size associated with disk storage.The operating system automatically loads pieces of a process into main memory as required.
  18. For virtual memory to be practical and effective, two ingredients are needed. there must be hardware support for the paging and/or segmentation scheme to be employed. the operating system must include software for managing the movement of pages and/or segments between secondary memoryand main memory.