SlideShare a Scribd company logo
1 of 34
Memory
Management
UNIX
Software
Hardware (Intel Pentium)
UNIX
MEMORY
MANAGEMENT
Swapping
Demand Paging
SWAPPING
Swapping is, in which a process in main memory is
copied to the preconfigured space on the hard
disk, called swap space, to free up that space of
memory.
The combined sizes of the physical memory and
the swap space is the amount of virtual memory
available.
Kernel allocates contiguous space on the swap
space and main memory.
It maintains free space of the swap space in an
internal table, called map.
As kernel allocates and frees resources, it
updates the map accordingly.
WHY IS SWAPPING
NECESSARY?
First, when the system requires more memory
than is physically available, the kernel swaps out
less used pages and gives memory to the current
application (process) that needs the memory
immediately.
Second, a significant number of the pages used by
an application during its start up phase may only
be used for initialization and then never used
again. The system can swap out those pages and
free the memory for other applications or even
for the disk cache.
DOWNSIDE OF SWAPPING
Compared to memory, disks are
very slow. So accessing the disk
can be tens or thousands times
slower than accessing physical
memory. The more swapping that
occurs, the slower your system will
be.
ALLOCATING SWAP SPACE
FREEING SWAP SPACE
SWAPPING PROCESS OUT
Memory Swap device
Kernel swaps out when memory is needed
When fork() called for allocate child process
When process become larger by growth of its stack
Previously swapped out process want to swap in or a
new process wants to come it but not enough memory
SWAPPING PROCESS IN
Swap Device Memory
Kernel swaps in
When a new process needs to be executed
When a previous process which was swapped
out wants to continue its execution
SWAPPING IN SWAPPING OUT
DEMAND PAGING
Not all pages of a process reside in memory.
Pages should only be brought into memory if the
executing process demands them.
This is often referred to as lazy evaluation as only
those pages demanded by the process are
swapped from backing store to main memory.
Advantages:
– Less I/O needed
– Less memory needed
– Faster response
– Increased degree of multi programming
VALID-INVALID BIT
When the page is in memory, the bit is
set valid.
When the page is not in memory but is
currently on the disk or it does not
belong to the logical address space of
that process, the bit is invalid.
PAGE FAULT
When a process accesses a page that is
not a part of its working set or is not
present in the main memory, page fault
occurs.
Operating system looks at an internal
table to decide:
– Invalid reference abort
– Just not in memory
STEPS IN HANDLING A PAGE FAULT
WHAT HAPPENS WHEN NO FREE
FRAME EXISTS?
When no free frame exists in the main
memory we find one, using certain
algorithm, that is not currently being
used and page it out.
In UNIX, Not Recently Used(NRU)
algorithm is used to select the victim
page.
PENTIUM ARCHITECTURE
FOR MEMORY MANAGEMENT
It supports both pure segmentation and
segmentation with paging.
In Pentium systems, the CPU generates logical
addresses, which are given to the
segmentation unit.
The segmentation unit produces a linear
address for each logical address.
The linear address is then given to the paging unit,
which in turn generates the physical address in main
memory.
PENTIUM PURE
SEGMENTATION
The Pentium architecture allows a segment to be as
large as 4 GB, and the maximum number of
segments per process is 16 K.
The logical-address space of a process is divided
into two partitions :-
-The first partition consists of up to 8 K segments
that are private to that process.
-The second partition consists of up to 8 K
segments that are shared all the processes.
Information about the first partition is kept in
LOCAL DESCRIPTOR TABLE (LDT).
The information about the second Partition is kept
in the GLOBAL DESCRIPTOR TABLE(GDT).
Each entry in the LDT and GDT consists of an 8-
byte segment descriptor with detailed information
about a particular segment, including the base
location and limit of that segment.
The logical address is a pair, where the selector is
a 16 -bit number and the offset is of 32- bits.
+
32
= 48 bits logical
address
Logical address space
Private segments
(8K)
Global segments
(8K)
GDT
LDT
limit base
limit base
s designates the segment number, g indicate whether the segment
is in the GDT or LDT, and p deals with protection.
The offset is a 32-bit number specifying the location of
the byte (or word) within the segment in question.
The machine has six segment registers, allowing six
segments to be addressed at any one time by a process.
It also has six 8-byte micro-program registers to hold
the corresponding descriptors from either the LDT or
GDT.
This cache lets the Pentium avoid having to read the
descriptor from memory for every memory reference.
The linear address on the Pentium is 32 bits long and is formed as
follows.
The segment register points to the appropriate entry in the LDT
or GDT. The base and limit information about the segment in
question is used to generate a linear address .
First, the limit is used to check for address validity.
If the address is not valid, a memory fault is generated, resulting
in a trap to the operating system.
If it is valid, then the value of the offset is added to the value of
the base, resulting in a 32-bit linear address.
PENTIUM SEGMENTATION
WITH PAGING
The Pentium architecture allows a page size of either 4 KB or 4
MB.
It uses a 32 bit linear address which is divided as follows:
-The 10 high-order bits referes to an entry in the page
directory.
-The page directory entry points to an inner page table that is
indexed by the contents of the innermost 10 bits in the linear
address.
-Finally, the low-order bits 0-11 refer to the offset in the 4-KB
page pointed to in the page table.
One entry in the page directory is the
Page Size flag, which-if set indicates
that the size of the page frame is 4 MB
and not the standard 4 KB.
If this flag is set, the page directory
points directly to the 4-MB page frame,
and the 22 low-order bits in the linear
address refer to the offset in the 4-
MB page frame.
To improve the efficiency of physical
memory use, Intel Pentium page tables can
be swapped to disk.
In this case, an invalid bit is used in the page
directory entry to indicate whether the
table to which the entry is pointing is in
memory or on disk.
If the table is on disk, the operating system
can use the other 31 bits to specify the disk
location of the table; the table then can be
brought into memory on demand.
SEGMENTATION
ADVANTAGES
Protection to different segments.
Enable sharing of selected segments.
Easier to locate segment than entire address
space.
DISADVANTAGES
Still expensive.
Difficult to allocate contiguous memory to
segments.
External fragmentation: waste memory.
PAGING
ADVANTAGES
Easy to swap out memory to disk:
- frame size matches disk block size.
- swap-in and swap-out between memory
and disk becomes easier.
Eliminate external fragmentation.
DISADVANTAGES
Internal fragmentation.
ADVANTAGE OF SEGMENTATION WITH PAGING
Increases flexibility of sharing
- Share at two levels-page or segment.
BIBLIOGRAPHY
Operating System Concepts by Abraham
Silberschatz, Greg Gagne, Peter Baer
Galvin
www.linux.com
www.tutorialspoint.com

More Related Content

What's hot

file system in operating system
file system in operating systemfile system in operating system
file system in operating systemtittuajay
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMSkoolkampus
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systemsvampugani
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques Kalhan Liyanage
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System ImplementationWayne Jones Jnr
 
memory management of windows vs linux
memory management of windows vs linuxmemory management of windows vs linux
memory management of windows vs linuxSumit Khanka
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory managementrprajat007
 
Andrew File System
Andrew File SystemAndrew File System
Andrew File SystemAshish KC
 
File organization
File organizationFile organization
File organizationGokul017
 
Linux kernel architecture
Linux kernel architectureLinux kernel architecture
Linux kernel architectureSHAJANA BASHEER
 
Processes in unix
Processes in unixProcesses in unix
Processes in unixmiau_max
 
Operating System-Memory Management
Operating System-Memory ManagementOperating System-Memory Management
Operating System-Memory ManagementAkmal Cikmat
 
Operating Systems: Device Management
Operating Systems: Device ManagementOperating Systems: Device Management
Operating Systems: Device ManagementDamian T. Gordon
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managmentSantu Kumar
 

What's hot (20)

file system in operating system
file system in operating systemfile system in operating system
file system in operating system
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systems
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
Linux memory
Linux memoryLinux memory
Linux memory
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System Implementation
 
memory management of windows vs linux
memory management of windows vs linuxmemory management of windows vs linux
memory management of windows vs linux
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 
Andrew File System
Andrew File SystemAndrew File System
Andrew File System
 
File organization
File organizationFile organization
File organization
 
Linux kernel architecture
Linux kernel architectureLinux kernel architecture
Linux kernel architecture
 
Spatial Database
Spatial DatabaseSpatial Database
Spatial Database
 
Processes in unix
Processes in unixProcesses in unix
Processes in unix
 
Unix ch03-03(2)
Unix ch03-03(2)Unix ch03-03(2)
Unix ch03-03(2)
 
Operating System-Memory Management
Operating System-Memory ManagementOperating System-Memory Management
Operating System-Memory Management
 
Operating Systems: Device Management
Operating Systems: Device ManagementOperating Systems: Device Management
Operating Systems: Device Management
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managment
 
Database System Architecture
Database System ArchitectureDatabase System Architecture
Database System Architecture
 
RAID LEVELS
RAID LEVELSRAID LEVELS
RAID LEVELS
 

Viewers also liked

Windows memory management
Windows memory managementWindows memory management
Windows memory managementTech_MX
 
Memory management in Linux
Memory management in LinuxMemory management in Linux
Memory management in LinuxRaghu Udiyar
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating Systemsubhsikha
 
Unix operating system
Unix operating systemUnix operating system
Unix operating systemABhay Panchal
 
Unix Process management
Unix Process managementUnix Process management
Unix Process managementWave Digitech
 
Operating System (Scheduling, Input and Output Management, Memory Management,...
Operating System (Scheduling, Input and Output Management, Memory Management,...Operating System (Scheduling, Input and Output Management, Memory Management,...
Operating System (Scheduling, Input and Output Management, Memory Management,...Project Student
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAnuj Modi
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File ManagementDamian T. Gordon
 
Chapter 13 file systems
Chapter 13   file systemsChapter 13   file systems
Chapter 13 file systemsAlvin Chin
 
Memory management
Memory managementMemory management
Memory managementcpjcollege
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management Shashank Asthana
 
Segmentation fault (Web - Site - Project)
Segmentation fault (Web - Site - Project)Segmentation fault (Web - Site - Project)
Segmentation fault (Web - Site - Project)George Tzinos
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory ManagementRajan Kandel
 
Memory Management | Computer Science
Memory Management | Computer ScienceMemory Management | Computer Science
Memory Management | Computer ScienceTransweb Global Inc
 
Presentation on Virtual Memory concepts in computer
Presentation on Virtual Memory concepts in computer Presentation on Virtual Memory concepts in computer
Presentation on Virtual Memory concepts in computer Oshin Kandpal
 
40 demand paging
40 demand paging40 demand paging
40 demand pagingmyrajendra
 

Viewers also liked (20)

Windows memory management
Windows memory managementWindows memory management
Windows memory management
 
Memory management in Linux
Memory management in LinuxMemory management in Linux
Memory management in Linux
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
 
Unix operating system
Unix operating systemUnix operating system
Unix operating system
 
Unix Process management
Unix Process managementUnix Process management
Unix Process management
 
Operating System (Scheduling, Input and Output Management, Memory Management,...
Operating System (Scheduling, Input and Output Management, Memory Management,...Operating System (Scheduling, Input and Output Management, Memory Management,...
Operating System (Scheduling, Input and Output Management, Memory Management,...
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Virtual memory ppt
Virtual memory pptVirtual memory ppt
Virtual memory ppt
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File Management
 
Chapter 13 file systems
Chapter 13   file systemsChapter 13   file systems
Chapter 13 file systems
 
Memory management
Memory managementMemory management
Memory management
 
Input output in linux
Input output in linuxInput output in linux
Input output in linux
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
 
Segmentation fault (Web - Site - Project)
Segmentation fault (Web - Site - Project)Segmentation fault (Web - Site - Project)
Segmentation fault (Web - Site - Project)
 
C dynamic ppt
C dynamic pptC dynamic ppt
C dynamic ppt
 
Thermal physics
Thermal physicsThermal physics
Thermal physics
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
Memory Management | Computer Science
Memory Management | Computer ScienceMemory Management | Computer Science
Memory Management | Computer Science
 
Presentation on Virtual Memory concepts in computer
Presentation on Virtual Memory concepts in computer Presentation on Virtual Memory concepts in computer
Presentation on Virtual Memory concepts in computer
 
40 demand paging
40 demand paging40 demand paging
40 demand paging
 

Similar to Memory Management Techniques in UNIX: Swapping and Demand Paging

Paging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory managementPaging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory managementkazim Hussain
 
Unit 5Memory management.pptx
Unit 5Memory management.pptxUnit 5Memory management.pptx
Unit 5Memory management.pptxSourabhRaj29
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OSC.U
 
Bab 4
Bab 4Bab 4
Bab 4n k
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memoryMazin Alwaaly
 
Paging and Segmentation
Paging and SegmentationPaging and Segmentation
Paging and SegmentationMadhur Gupta
 
PAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorKanchanPatil34
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating SystemRaj Mohan
 
Memory management
Memory managementMemory management
Memory managementRasi123
 

Similar to Memory Management Techniques in UNIX: Swapping and Demand Paging (20)

Cs416 08 09a
Cs416 08 09aCs416 08 09a
Cs416 08 09a
 
virtual memory
virtual memoryvirtual memory
virtual memory
 
Paging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory managementPaging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory management
 
Unit 5Memory management.pptx
Unit 5Memory management.pptxUnit 5Memory management.pptx
Unit 5Memory management.pptx
 
OSCh9
OSCh9OSCh9
OSCh9
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
 
OS_Ch9
OS_Ch9OS_Ch9
OS_Ch9
 
Bab 4
Bab 4Bab 4
Bab 4
 
Memory management
Memory managementMemory management
Memory management
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
 
Os4
Os4Os4
Os4
 
Os4
Os4Os4
Os4
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memory
 
Paging and Segmentation
Paging and SegmentationPaging and Segmentation
Paging and Segmentation
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Memory comp
Memory compMemory comp
Memory comp
 
PAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 Microporcessor
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
 
Memory management
Memory managementMemory management
Memory management
 
Memory+management
Memory+managementMemory+management
Memory+management
 

More from Drishti Bhalla

Propositions - Discrete Structures
Propositions - Discrete Structures Propositions - Discrete Structures
Propositions - Discrete Structures Drishti Bhalla
 
Physical Layer Numericals - Data Communication & Networking
Physical Layer  Numericals - Data Communication & NetworkingPhysical Layer  Numericals - Data Communication & Networking
Physical Layer Numericals - Data Communication & NetworkingDrishti Bhalla
 
Determinants - Mathematics
Determinants - MathematicsDeterminants - Mathematics
Determinants - MathematicsDrishti Bhalla
 
Matrices - Mathematics
Matrices - MathematicsMatrices - Mathematics
Matrices - MathematicsDrishti Bhalla
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsDrishti Bhalla
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - JavaDrishti Bhalla
 
Airline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringAirline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringDrishti Bhalla
 
Performance Management and Feedback - SHRM
Performance Management and Feedback - SHRMPerformance Management and Feedback - SHRM
Performance Management and Feedback - SHRMDrishti Bhalla
 
Computer System Architecture - BUN instruction
Computer System Architecture - BUN instructionComputer System Architecture - BUN instruction
Computer System Architecture - BUN instructionDrishti Bhalla
 
King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4Drishti Bhalla
 
Information Technology - System Threats
Information Technology - System ThreatsInformation Technology - System Threats
Information Technology - System ThreatsDrishti Bhalla
 
Software Metrics - Software Engineering
Software Metrics - Software EngineeringSoftware Metrics - Software Engineering
Software Metrics - Software EngineeringDrishti Bhalla
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationDrishti Bhalla
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management SystemDrishti Bhalla
 

More from Drishti Bhalla (16)

Propositions - Discrete Structures
Propositions - Discrete Structures Propositions - Discrete Structures
Propositions - Discrete Structures
 
Physical Layer Numericals - Data Communication & Networking
Physical Layer  Numericals - Data Communication & NetworkingPhysical Layer  Numericals - Data Communication & Networking
Physical Layer Numericals - Data Communication & Networking
 
Determinants - Mathematics
Determinants - MathematicsDeterminants - Mathematics
Determinants - Mathematics
 
Matrices - Mathematics
Matrices - MathematicsMatrices - Mathematics
Matrices - Mathematics
 
Holy Rivers - Hindi
Holy Rivers - HindiHoly Rivers - Hindi
Holy Rivers - Hindi
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - Java
 
Airline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringAirline Reservation System - Software Engineering
Airline Reservation System - Software Engineering
 
Performance Management and Feedback - SHRM
Performance Management and Feedback - SHRMPerformance Management and Feedback - SHRM
Performance Management and Feedback - SHRM
 
Computer System Architecture - BUN instruction
Computer System Architecture - BUN instructionComputer System Architecture - BUN instruction
Computer System Architecture - BUN instruction
 
King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4
 
Information Technology - System Threats
Information Technology - System ThreatsInformation Technology - System Threats
Information Technology - System Threats
 
Software Metrics - Software Engineering
Software Metrics - Software EngineeringSoftware Metrics - Software Engineering
Software Metrics - Software Engineering
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of Computation
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management System
 

Recently uploaded

Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 

Recently uploaded (20)

Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 

Memory Management Techniques in UNIX: Swapping and Demand Paging

  • 3. SWAPPING Swapping is, in which a process in main memory is copied to the preconfigured space on the hard disk, called swap space, to free up that space of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available. Kernel allocates contiguous space on the swap space and main memory. It maintains free space of the swap space in an internal table, called map. As kernel allocates and frees resources, it updates the map accordingly.
  • 4. WHY IS SWAPPING NECESSARY? First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its start up phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.
  • 5. DOWNSIDE OF SWAPPING Compared to memory, disks are very slow. So accessing the disk can be tens or thousands times slower than accessing physical memory. The more swapping that occurs, the slower your system will be.
  • 8. SWAPPING PROCESS OUT Memory Swap device Kernel swaps out when memory is needed When fork() called for allocate child process When process become larger by growth of its stack Previously swapped out process want to swap in or a new process wants to come it but not enough memory
  • 9. SWAPPING PROCESS IN Swap Device Memory Kernel swaps in When a new process needs to be executed When a previous process which was swapped out wants to continue its execution
  • 11. DEMAND PAGING Not all pages of a process reside in memory. Pages should only be brought into memory if the executing process demands them. This is often referred to as lazy evaluation as only those pages demanded by the process are swapped from backing store to main memory. Advantages: – Less I/O needed – Less memory needed – Faster response – Increased degree of multi programming
  • 12.
  • 13. VALID-INVALID BIT When the page is in memory, the bit is set valid. When the page is not in memory but is currently on the disk or it does not belong to the logical address space of that process, the bit is invalid.
  • 14. PAGE FAULT When a process accesses a page that is not a part of its working set or is not present in the main memory, page fault occurs. Operating system looks at an internal table to decide: – Invalid reference abort – Just not in memory
  • 15. STEPS IN HANDLING A PAGE FAULT
  • 16. WHAT HAPPENS WHEN NO FREE FRAME EXISTS? When no free frame exists in the main memory we find one, using certain algorithm, that is not currently being used and page it out. In UNIX, Not Recently Used(NRU) algorithm is used to select the victim page.
  • 17.
  • 18. PENTIUM ARCHITECTURE FOR MEMORY MANAGEMENT It supports both pure segmentation and segmentation with paging. In Pentium systems, the CPU generates logical addresses, which are given to the segmentation unit. The segmentation unit produces a linear address for each logical address.
  • 19. The linear address is then given to the paging unit, which in turn generates the physical address in main memory.
  • 20. PENTIUM PURE SEGMENTATION The Pentium architecture allows a segment to be as large as 4 GB, and the maximum number of segments per process is 16 K. The logical-address space of a process is divided into two partitions :- -The first partition consists of up to 8 K segments that are private to that process. -The second partition consists of up to 8 K segments that are shared all the processes.
  • 21. Information about the first partition is kept in LOCAL DESCRIPTOR TABLE (LDT). The information about the second Partition is kept in the GLOBAL DESCRIPTOR TABLE(GDT). Each entry in the LDT and GDT consists of an 8- byte segment descriptor with detailed information about a particular segment, including the base location and limit of that segment. The logical address is a pair, where the selector is a 16 -bit number and the offset is of 32- bits. + 32 = 48 bits logical address
  • 22. Logical address space Private segments (8K) Global segments (8K) GDT LDT limit base limit base s designates the segment number, g indicate whether the segment is in the GDT or LDT, and p deals with protection.
  • 23. The offset is a 32-bit number specifying the location of the byte (or word) within the segment in question. The machine has six segment registers, allowing six segments to be addressed at any one time by a process. It also has six 8-byte micro-program registers to hold the corresponding descriptors from either the LDT or GDT. This cache lets the Pentium avoid having to read the descriptor from memory for every memory reference.
  • 24. The linear address on the Pentium is 32 bits long and is formed as follows. The segment register points to the appropriate entry in the LDT or GDT. The base and limit information about the segment in question is used to generate a linear address . First, the limit is used to check for address validity. If the address is not valid, a memory fault is generated, resulting in a trap to the operating system. If it is valid, then the value of the offset is added to the value of the base, resulting in a 32-bit linear address.
  • 25.
  • 26. PENTIUM SEGMENTATION WITH PAGING The Pentium architecture allows a page size of either 4 KB or 4 MB. It uses a 32 bit linear address which is divided as follows: -The 10 high-order bits referes to an entry in the page directory. -The page directory entry points to an inner page table that is indexed by the contents of the innermost 10 bits in the linear address. -Finally, the low-order bits 0-11 refer to the offset in the 4-KB page pointed to in the page table.
  • 27.
  • 28. One entry in the page directory is the Page Size flag, which-if set indicates that the size of the page frame is 4 MB and not the standard 4 KB. If this flag is set, the page directory points directly to the 4-MB page frame, and the 22 low-order bits in the linear address refer to the offset in the 4- MB page frame.
  • 29. To improve the efficiency of physical memory use, Intel Pentium page tables can be swapped to disk. In this case, an invalid bit is used in the page directory entry to indicate whether the table to which the entry is pointing is in memory or on disk. If the table is on disk, the operating system can use the other 31 bits to specify the disk location of the table; the table then can be brought into memory on demand.
  • 30.
  • 31. SEGMENTATION ADVANTAGES Protection to different segments. Enable sharing of selected segments. Easier to locate segment than entire address space. DISADVANTAGES Still expensive. Difficult to allocate contiguous memory to segments. External fragmentation: waste memory.
  • 32. PAGING ADVANTAGES Easy to swap out memory to disk: - frame size matches disk block size. - swap-in and swap-out between memory and disk becomes easier. Eliminate external fragmentation. DISADVANTAGES Internal fragmentation.
  • 33. ADVANTAGE OF SEGMENTATION WITH PAGING Increases flexibility of sharing - Share at two levels-page or segment.
  • 34. BIBLIOGRAPHY Operating System Concepts by Abraham Silberschatz, Greg Gagne, Peter Baer Galvin www.linux.com www.tutorialspoint.com