SlideShare a Scribd company logo
1 of 14
Download to read offline
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56
OPERATING SYSTEM
Mr. Anand H. D.
1
Department of Electronics & Communication Engineering
Dr. Ambedkar Institute of Technology
Bengaluru-56
Operating System: VIRTUAL MEMORY
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 2
Operating System: VIRTUAL MEMORY
Virtual memory Basics Demand paging
Page replacement policies
Topics to be covered:
 Virtual memory Basics
 Demand paging
 Page replacement policies
Virtual memory Basics Demand paging
Page replacement policies
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 3
Virtual memory Basics
 Users always want more from a computer system—more resources and more services. The need
for more resources is satisfied either by obtaining more efficient use of existing resources, or by
creating an illusion that more resources exist in the system.
 A virtual memory is what its name indicates—it is an illusion of a memory that is larger than
the real memory, i.e., RAM, of the computer system. A user or his application program sees
only the virtual memory.
 The kernel implements the illusion through a combination of hardware and software means.
We refer to real memory simply as memory. We refer to the software component of virtual
memory as a virtual memory manager.
 The illusion of memory larger than the system’s memory crops up any time a process whose
size exceeds the size of memory is initiated. The process is able to operate because it is kept in
its entirety on a disk and only its required portions are loaded in memory at any time.
 The basis of virtual memory is the noncontiguous memory allocation model described earlier in.
The address space of each process is assumed to consist of portions called components. The
portions can be loaded into nonadjacent areas of memory.
Operating System: VIRTUAL MEMORY
Virtual memory Basics Demand paging
Page replacement policies
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4
Virtual memory Basics
 The address of each operand or instruction in the code of a process is a logical address of the
form (compi, bytei).
 The memory management unit (MMU) translates it into the address in memory where the
operand or instruction actually resides. Use of the noncontiguous memory allocation model
reduces memory fragmentation, since a free area of memory can be reused even if it is not large
enough to hold the entire address space of a process. More user processes can be
accommodated in memory this way, which benefits both users and the OS.
Operating System: VIRTUAL MEMORY
 The kernel carries this idea further—even
processes that can fit in memory are not
loaded fully into memory. This strategy
reduces the amount of memory that is
allocated to each process, thus further
increasing the number of processes that can
be in operation at the same time.
Figure shows a schematic diagram of a virtual
memory.
Virtual memory Basics Demand paging
Page replacement policies
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 5
Virtual memory Basics
 The logical address space of the process shown consists of five components. Three of these
components are presently in memory. Information about the memory areas where these
components exist is maintained in a data structure of the virtual memory manager. This
information is used by the MMU during address translation. When an instruction in the
process refers to a data item or instruction that is not in memory, the component containing it
is loaded from the disk. Occasionally, the virtual memory manager removes some components
from memory to make room for other components.
 The arrangement shown in Figure is a memory hierarchy as discussed earlier. The hierarchy
consists of the system’s memory and a disk. Memory is fast, but small in size. The disk is slow,
but has a much larger capacity.
 The MMU and the virtual memory manager together manage the memory hierarchy, so that the
current instruction in a process finds its operands in memory. We are now ready to define
virtual memory.
 Virtual Memory: A memory hierarchy, consisting of a computer system’s memory and a disk,
that enables a process to operate with only some portions of its address space in memory.
Operating System: VIRTUAL MEMORY
Virtual memory Basics Demand paging
Page replacement policies
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 6
Virtual memory Basics
 Demand Loading of Process Components The virtual memory manager loads only one
component of a process address space in memory to begin with—the component that contains
the start address of the process, that is, address of the instruction with which its execution
begins. It loads other components of the process only when they are needed. This technique is
called demand loading.
To keep the memory commitment to a process low, the virtual memory manager removes
components of the process from memory from time to time. These components would be loaded
back in memory when needed again.
Performance of a process in virtual memory depends on the rate at which its
components have to be loaded into memory. The virtual memory manager exploits the law of
locality of reference to achieve a low rate of loading of process components.
Operating System: VIRTUAL MEMORY
Virtual memory Basics Demand paging
Page replacement policies
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 7
Virtual memory Basics
 Paging and Segmentation: Implementation
of virtual memory differ in the manner in
which the boundaries and sizes of address
space components are determined. Table
compares the two approaches. In paging,
each component of an address space is
called a page. All pages have identical size,
which is a power of two. Page size is defined
by the computer hardware and demarcation
of pages in the address space of a process is
performed implicitly by it. In segmentation,
each component of an address space is
called a segment. A programmer declares
some significant logical entities (e.g., data
structures or objects) in a process as
segments.
Operating System: VIRTUAL MEMORY
Virtual memory Basics Demand paging
Page replacement policies
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 8
Virtual memory Basics
 Thus identification of components is performed by the programmer, and segments can have
different sizes. This fundamental difference leads to different implications for efficient use of
memory and for sharing of programs or data. Some systems use a hybrid segmentation-with-
paging approach to obtain advantages of both the approaches.
 In paging, each component of an address space is called a page. All pages have identical size,
which is a power of two. Page size is defined by the computer hardware and demarcation of
pages in the address space of a process is performed implicitly by it. In segmentation, each
component of an address space is called a segment.
 A programmer declares some significant logical entities (e.g., data structures or objects) in a
process as segments. Thus identification of components is performed by the programmer, and
segments can have different sizes. This fundamental difference leads to different implications
for efficient use of memory and for sharing of programs or data. Some systems use a hybrid
segmentation-with-paging approach to obtain advantages of both the approaches.
Operating System: VIRTUAL MEMORY
Virtual memory Basics Demand paging
Page replacement policies
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 9
Virtual memory Basics Demand paging
A process is considered to consist of pages, numbered from 0 onward. Each page is of
size s bytes, where s is a power of 2. The memory of the computer system is considered
to consist of page frames, where a page frame is a memory area that has the same size
as a page.
Page frames are numbered from 0 to #frames-1 where #frames is the number of page
frames of memory. Accordingly, the physical address space consists of addresses from 0
to #frames × s - 1.
At any moment, a page frame may be free, or it may contain a page of some process.
Each logical address used in a process is considered to be a pair (pi, bi), where pi is a
page number and bi is the byte number in pi, 0 ≤ bi < s. The effective memory address of
a logical address (pi, bi) is computed as follows:
Effective memory address of logical address (pi, bi) = start address of the page frame
containing page pi + bi
The size of a page is a power of 2, and so calculation of the effective address is
performed through bit concatenation, which is much faster than addition
Operating System: VIRTUAL MEMORY
Virtual memory Basics Demand paging
Page replacement policies
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10
Virtual memory Basics Demand paging
Figure is a schematic diagram of a virtual memory
using paging in which page size is assumed to be
1 KB, where 1 KB = 1024 bytes. Three processes
P1, P2 and P3, have some of their pages in
memory.
The memory contains 8 page frames numbered
from 0 to 7. Memory allocation information for a
process is stored in a page table. Each entry in the
page table contains memory allocation information
for one page of a process. It contains the page
frame number where a page resides.
Operating System: VIRTUAL MEMORY
Process P2 has its pages 1 and 2 in memory. They occupy page frames 5 and 7 respectively. Process P1 has its
pages 0 and 2 in page frames 4 and 1, while process P3 has its pages 1, 3 and 4 in page frames 0, 2 and 3,
respectively. The free frames list contains a list of free page frames. Currently only page frame 6 is free.
Process P2 is currently executing the instruction ‘Add ·· 2528’, so the MMU uses P2’s page table for address
translation. The MMU views the operand address 2528 as the pair (2, 480) because 2528 = 2 × 1024 + 480. It
now accesses the entry for page 2 in P2’s page table. This entry contains frame number 7, so the MMU forms
the effective address 7 × 1024 + 480 according to Eq. (12.1), and uses it to make a memory access. In effect,
byte 480 in page frame 7 is accessed.
Virtual memory Basics Demand paging
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 11
 A page replacement policy should replace a page that is not likely to be referenced in the
immediate future. We evaluate the following three page replacement policies to see how well
they fulfill this requirement.
• Optimal page replacement policy
• First-in, first-out (FIFO) page replacement policy
• Least recently used (LRU) page replacement policy
Page replacement policies
Operating System: VIRTUAL MEMORY
Optimal Page Replacement: Optimal page replacement means making page replacement decisions
in such a manner that the total number of page faults during operation of a process is the minimum
possible; i.e., no other sequence of page replacement decisions can lead to a smaller number of page
faults. To achieve optimal page replacement, at each page fault, the page replacement policy would
have to consider all alternative page replacement decisions, analyze their implications for future page
faults, and select the best alternative. Of course, such a policy is infeasible in reality: the virtual
memory manager does not have knowledge of the future behavior of a process. As an analytical tool,
however, this policy provides a useful comparison in hindsight for the performance of other page
replacement policies. Although optimal page replacement might seem to require excessive analysis,
Belady (1966) showed that it is equivalent to the following simple rule: At a page fault, replace the
page whose next reference is farthest in the page reference string.
Virtual memory Basics Demand paging
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 12
Page replacement policies
Operating System: VIRTUAL MEMORY
FIFO Page Replacement At every page fault, the FIFO page replacement policy replaces the
page that was loaded into memory earlier than any other page of the process. To facilitate
FIFO page replacement, the virtual memory manager records the time of loading of a page in
the ref info field of its page table entry. When a page fault occurs, this information is used to
determine pearliest, the page that was loaded earlier than any other page of the process.
This is the page that will be replaced with the page whose reference led to the page fault.
LRU Page Replacement: The LRU policy uses the law of locality of reference as the basis
for its replacement decisions. Its operation can be described as follows: At every page fault
the least recently used (LRU) page is replaced by the required page. The page table entry of a
page records the time when the page was last referenced. This information is initialized
when a page is loaded, and it is updated every time the page is referenced. When a page
fault occurs, this information is used to locate the page pLRU whose last reference is earlier
than that of every other page. This page is replaced with the page whose reference led to the
page fault.
Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13
Reference
1. D.M.Dhamdhare, “Operating Systems”,
Second Edition, TMH, 2008
Operating System: VIRTUAL MEMORY
Virtual memory Basics Demand paging
Page replacement policies
14
Prof. Anand H. D.
M. Tech. (PhD.)
Assistant Professor,
Department of Electronics & Communication Engineering
Dr. Ambedkar Institute of Technology, Bengaluru-56
Email: anandhdece@dr-ait.org
Phone: 9844518832

More Related Content

What's hot

Characteristics and Quality Attributes of Embedded System
Characteristics and Quality Attributes of Embedded SystemCharacteristics and Quality Attributes of Embedded System
Characteristics and Quality Attributes of Embedded Systemanand hd
 
PI-Tool To Improve Performance of Application In Multi-core Architecture
PI-Tool To Improve Performance of Application In Multi-core ArchitecturePI-Tool To Improve Performance of Application In Multi-core Architecture
PI-Tool To Improve Performance of Application In Multi-core ArchitectureCSCJournals
 
COMPARATIVE ANALYSIS OF FCFS, SJN & RR JOB SCHEDULING ALGORITHMS
COMPARATIVE ANALYSIS OF FCFS, SJN & RR JOB SCHEDULING ALGORITHMSCOMPARATIVE ANALYSIS OF FCFS, SJN & RR JOB SCHEDULING ALGORITHMS
COMPARATIVE ANALYSIS OF FCFS, SJN & RR JOB SCHEDULING ALGORITHMSijcsit
 
Operating system concepts ninth edition (2012), chapter 2 solution e1
Operating system concepts ninth edition (2012), chapter 2 solution e1Operating system concepts ninth edition (2012), chapter 2 solution e1
Operating system concepts ninth edition (2012), chapter 2 solution e1Navid Daneshvaran
 
RTOS for Embedded System Design
RTOS for Embedded System DesignRTOS for Embedded System Design
RTOS for Embedded System Designanand hd
 
A Parallel Computing-a Paradigm to achieve High Performance
A Parallel Computing-a Paradigm to achieve High PerformanceA Parallel Computing-a Paradigm to achieve High Performance
A Parallel Computing-a Paradigm to achieve High PerformanceAM Publications
 
Os files 2
Os files 2Os files 2
Os files 2Amit Pal
 
A Runtime Evaluation Methodology and Framework for Autonomic Systems
A Runtime Evaluation Methodology and Framework for Autonomic SystemsA Runtime Evaluation Methodology and Framework for Autonomic Systems
A Runtime Evaluation Methodology and Framework for Autonomic SystemsIDES Editor
 
VIEW OF MEMORY ALLOCATION AND MANAGEMENT IN COMPUTER SYSTEMS
VIEW OF MEMORY ALLOCATION AND MANAGEMENT IN COMPUTER SYSTEMSVIEW OF MEMORY ALLOCATION AND MANAGEMENT IN COMPUTER SYSTEMS
VIEW OF MEMORY ALLOCATION AND MANAGEMENT IN COMPUTER SYSTEMScseij
 
AN EFFICIENT HYBRID SCHEDULER USING DYNAMIC SLACK FOR REAL-TIME CRITICAL TASK...
AN EFFICIENT HYBRID SCHEDULER USING DYNAMIC SLACK FOR REAL-TIME CRITICAL TASK...AN EFFICIENT HYBRID SCHEDULER USING DYNAMIC SLACK FOR REAL-TIME CRITICAL TASK...
AN EFFICIENT HYBRID SCHEDULER USING DYNAMIC SLACK FOR REAL-TIME CRITICAL TASK...ijesajournal
 
CSI-503 - 6. Memory Management
CSI-503 - 6. Memory Management CSI-503 - 6. Memory Management
CSI-503 - 6. Memory Management ghayour abbas
 
VTU 5TH SEM CSE SOFTWARE ENGINEERING SOLVED PAPERS - JUN13 DEC13 JUN14 DEC14 ...
VTU 5TH SEM CSE SOFTWARE ENGINEERING SOLVED PAPERS - JUN13 DEC13 JUN14 DEC14 ...VTU 5TH SEM CSE SOFTWARE ENGINEERING SOLVED PAPERS - JUN13 DEC13 JUN14 DEC14 ...
VTU 5TH SEM CSE SOFTWARE ENGINEERING SOLVED PAPERS - JUN13 DEC13 JUN14 DEC14 ...vtunotesbysree
 
Software rejuvenation
Software rejuvenationSoftware rejuvenation
Software rejuvenationRVCE
 

What's hot (16)

Characteristics and Quality Attributes of Embedded System
Characteristics and Quality Attributes of Embedded SystemCharacteristics and Quality Attributes of Embedded System
Characteristics and Quality Attributes of Embedded System
 
Memory
MemoryMemory
Memory
 
PI-Tool To Improve Performance of Application In Multi-core Architecture
PI-Tool To Improve Performance of Application In Multi-core ArchitecturePI-Tool To Improve Performance of Application In Multi-core Architecture
PI-Tool To Improve Performance of Application In Multi-core Architecture
 
COMPARATIVE ANALYSIS OF FCFS, SJN & RR JOB SCHEDULING ALGORITHMS
COMPARATIVE ANALYSIS OF FCFS, SJN & RR JOB SCHEDULING ALGORITHMSCOMPARATIVE ANALYSIS OF FCFS, SJN & RR JOB SCHEDULING ALGORITHMS
COMPARATIVE ANALYSIS OF FCFS, SJN & RR JOB SCHEDULING ALGORITHMS
 
Operating system concepts ninth edition (2012), chapter 2 solution e1
Operating system concepts ninth edition (2012), chapter 2 solution e1Operating system concepts ninth edition (2012), chapter 2 solution e1
Operating system concepts ninth edition (2012), chapter 2 solution e1
 
RTOS for Embedded System Design
RTOS for Embedded System DesignRTOS for Embedded System Design
RTOS for Embedded System Design
 
A Parallel Computing-a Paradigm to achieve High Performance
A Parallel Computing-a Paradigm to achieve High PerformanceA Parallel Computing-a Paradigm to achieve High Performance
A Parallel Computing-a Paradigm to achieve High Performance
 
Os files 2
Os files 2Os files 2
Os files 2
 
A Runtime Evaluation Methodology and Framework for Autonomic Systems
A Runtime Evaluation Methodology and Framework for Autonomic SystemsA Runtime Evaluation Methodology and Framework for Autonomic Systems
A Runtime Evaluation Methodology and Framework for Autonomic Systems
 
VIEW OF MEMORY ALLOCATION AND MANAGEMENT IN COMPUTER SYSTEMS
VIEW OF MEMORY ALLOCATION AND MANAGEMENT IN COMPUTER SYSTEMSVIEW OF MEMORY ALLOCATION AND MANAGEMENT IN COMPUTER SYSTEMS
VIEW OF MEMORY ALLOCATION AND MANAGEMENT IN COMPUTER SYSTEMS
 
Firo
FiroFiro
Firo
 
AN EFFICIENT HYBRID SCHEDULER USING DYNAMIC SLACK FOR REAL-TIME CRITICAL TASK...
AN EFFICIENT HYBRID SCHEDULER USING DYNAMIC SLACK FOR REAL-TIME CRITICAL TASK...AN EFFICIENT HYBRID SCHEDULER USING DYNAMIC SLACK FOR REAL-TIME CRITICAL TASK...
AN EFFICIENT HYBRID SCHEDULER USING DYNAMIC SLACK FOR REAL-TIME CRITICAL TASK...
 
CSI-503 - 6. Memory Management
CSI-503 - 6. Memory Management CSI-503 - 6. Memory Management
CSI-503 - 6. Memory Management
 
VTU 5TH SEM CSE SOFTWARE ENGINEERING SOLVED PAPERS - JUN13 DEC13 JUN14 DEC14 ...
VTU 5TH SEM CSE SOFTWARE ENGINEERING SOLVED PAPERS - JUN13 DEC13 JUN14 DEC14 ...VTU 5TH SEM CSE SOFTWARE ENGINEERING SOLVED PAPERS - JUN13 DEC13 JUN14 DEC14 ...
VTU 5TH SEM CSE SOFTWARE ENGINEERING SOLVED PAPERS - JUN13 DEC13 JUN14 DEC14 ...
 
Os Question Bank
Os Question BankOs Question Bank
Os Question Bank
 
Software rejuvenation
Software rejuvenationSoftware rejuvenation
Software rejuvenation
 

Similar to OS virtual memory

Similar to OS virtual memory (20)

Memory Management in Operating System
Memory Management in Operating SystemMemory Management in Operating System
Memory Management in Operating System
 
An Efficient Virtual Memory using Graceful Code
An Efficient Virtual Memory using Graceful CodeAn Efficient Virtual Memory using Graceful Code
An Efficient Virtual Memory using Graceful Code
 
Paging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory managementPaging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory management
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Os unit 2
Os unit 2Os unit 2
Os unit 2
 
Module 4 memory management
Module 4 memory managementModule 4 memory management
Module 4 memory management
 
STORAGE MANAGEMENT AND PAGING ALGORITHMS.pptx
STORAGE MANAGEMENT AND PAGING ALGORITHMS.pptxSTORAGE MANAGEMENT AND PAGING ALGORITHMS.pptx
STORAGE MANAGEMENT AND PAGING ALGORITHMS.pptx
 
unit5_os (1).pptx
unit5_os (1).pptxunit5_os (1).pptx
unit5_os (1).pptx
 
OS Unit 2.pptx
OS Unit 2.pptxOS Unit 2.pptx
OS Unit 2.pptx
 
Unit 5Memory management.pptx
Unit 5Memory management.pptxUnit 5Memory management.pptx
Unit 5Memory management.pptx
 
Memory Management
Memory Management Memory Management
Memory Management
 
virtual memory
virtual memoryvirtual memory
virtual memory
 
Paging-R.D.Sivakumar
Paging-R.D.SivakumarPaging-R.D.Sivakumar
Paging-R.D.Sivakumar
 
Paging-R.D.Sivakumar
Paging-R.D.SivakumarPaging-R.D.Sivakumar
Paging-R.D.Sivakumar
 
Memory management
Memory managementMemory management
Memory management
 
Lecture 43
Lecture 43Lecture 43
Lecture 43
 
OSCh9
OSCh9OSCh9
OSCh9
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
 
OS_Ch9
OS_Ch9OS_Ch9
OS_Ch9
 
Operating Systems - memory management
Operating Systems - memory managementOperating Systems - memory management
Operating Systems - memory management
 

More from anand hd

RMV sensors
RMV sensorsRMV sensors
RMV sensorsanand hd
 
RMV robot programming
RMV robot programmingRMV robot programming
RMV robot programminganand hd
 
Robot applications
Robot applicationsRobot applications
Robot applicationsanand hd
 
RMV Mechanics
RMV MechanicsRMV Mechanics
RMV Mechanicsanand hd
 
Robot Machine Vision
Robot Machine VisionRobot Machine Vision
Robot Machine Visionanand hd
 
RMV Artificial Intelligence
RMV Artificial IntelligenceRMV Artificial Intelligence
RMV Artificial Intelligenceanand hd
 
Modules and ports in Verilog HDL
Modules and ports in Verilog HDLModules and ports in Verilog HDL
Modules and ports in Verilog HDLanand hd
 
Basic concepts in Verilog HDL
Basic concepts in Verilog HDLBasic concepts in Verilog HDL
Basic concepts in Verilog HDLanand hd
 
Overview of digital design with Verilog HDL
Overview of digital design with Verilog HDLOverview of digital design with Verilog HDL
Overview of digital design with Verilog HDLanand hd
 
Robotics Endeffectors
Robotics EndeffectorsRobotics Endeffectors
Robotics Endeffectorsanand hd
 
Fundamentals of Robotics and Machine Vision System
Fundamentals of Robotics and Machine Vision SystemFundamentals of Robotics and Machine Vision System
Fundamentals of Robotics and Machine Vision Systemanand hd
 
Robotics and Automation Introduction
Robotics and Automation IntroductionRobotics and Automation Introduction
Robotics and Automation Introductionanand hd
 
Programmable Logic Devices
Programmable Logic DevicesProgrammable Logic Devices
Programmable Logic Devicesanand hd
 
Logic synthesis using Verilog HDL
Logic synthesis using Verilog HDLLogic synthesis using Verilog HDL
Logic synthesis using Verilog HDLanand hd
 
Case Study of Embedded Systems
Case Study of Embedded SystemsCase Study of Embedded Systems
Case Study of Embedded Systemsanand hd
 
Modeling examples
Modeling examplesModeling examples
Modeling examplesanand hd
 
Verilog Tasks & Functions
Verilog Tasks & FunctionsVerilog Tasks & Functions
Verilog Tasks & Functionsanand hd
 
Concepts of Behavioral modelling in Verilog HDL
Concepts of Behavioral modelling in Verilog HDLConcepts of Behavioral modelling in Verilog HDL
Concepts of Behavioral modelling in Verilog HDLanand hd
 
ARM 32-bit Microcontroller Cortex-M3 introduction
ARM 32-bit Microcontroller Cortex-M3 introductionARM 32-bit Microcontroller Cortex-M3 introduction
ARM 32-bit Microcontroller Cortex-M3 introductionanand hd
 
Computational models
Computational modelsComputational models
Computational modelsanand hd
 

More from anand hd (20)

RMV sensors
RMV sensorsRMV sensors
RMV sensors
 
RMV robot programming
RMV robot programmingRMV robot programming
RMV robot programming
 
Robot applications
Robot applicationsRobot applications
Robot applications
 
RMV Mechanics
RMV MechanicsRMV Mechanics
RMV Mechanics
 
Robot Machine Vision
Robot Machine VisionRobot Machine Vision
Robot Machine Vision
 
RMV Artificial Intelligence
RMV Artificial IntelligenceRMV Artificial Intelligence
RMV Artificial Intelligence
 
Modules and ports in Verilog HDL
Modules and ports in Verilog HDLModules and ports in Verilog HDL
Modules and ports in Verilog HDL
 
Basic concepts in Verilog HDL
Basic concepts in Verilog HDLBasic concepts in Verilog HDL
Basic concepts in Verilog HDL
 
Overview of digital design with Verilog HDL
Overview of digital design with Verilog HDLOverview of digital design with Verilog HDL
Overview of digital design with Verilog HDL
 
Robotics Endeffectors
Robotics EndeffectorsRobotics Endeffectors
Robotics Endeffectors
 
Fundamentals of Robotics and Machine Vision System
Fundamentals of Robotics and Machine Vision SystemFundamentals of Robotics and Machine Vision System
Fundamentals of Robotics and Machine Vision System
 
Robotics and Automation Introduction
Robotics and Automation IntroductionRobotics and Automation Introduction
Robotics and Automation Introduction
 
Programmable Logic Devices
Programmable Logic DevicesProgrammable Logic Devices
Programmable Logic Devices
 
Logic synthesis using Verilog HDL
Logic synthesis using Verilog HDLLogic synthesis using Verilog HDL
Logic synthesis using Verilog HDL
 
Case Study of Embedded Systems
Case Study of Embedded SystemsCase Study of Embedded Systems
Case Study of Embedded Systems
 
Modeling examples
Modeling examplesModeling examples
Modeling examples
 
Verilog Tasks & Functions
Verilog Tasks & FunctionsVerilog Tasks & Functions
Verilog Tasks & Functions
 
Concepts of Behavioral modelling in Verilog HDL
Concepts of Behavioral modelling in Verilog HDLConcepts of Behavioral modelling in Verilog HDL
Concepts of Behavioral modelling in Verilog HDL
 
ARM 32-bit Microcontroller Cortex-M3 introduction
ARM 32-bit Microcontroller Cortex-M3 introductionARM 32-bit Microcontroller Cortex-M3 introduction
ARM 32-bit Microcontroller Cortex-M3 introduction
 
Computational models
Computational modelsComputational models
Computational models
 

Recently uploaded

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
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
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
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
 
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
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
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
 
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
 
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
 
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
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
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
 
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
 
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
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
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
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
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
 
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)
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
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
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
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...
 
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...
 
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
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.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
 
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
 
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
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 

OS virtual memory

  • 1. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 OPERATING SYSTEM Mr. Anand H. D. 1 Department of Electronics & Communication Engineering Dr. Ambedkar Institute of Technology Bengaluru-56 Operating System: VIRTUAL MEMORY
  • 2. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 2 Operating System: VIRTUAL MEMORY Virtual memory Basics Demand paging Page replacement policies Topics to be covered:  Virtual memory Basics  Demand paging  Page replacement policies
  • 3. Virtual memory Basics Demand paging Page replacement policies Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 3 Virtual memory Basics  Users always want more from a computer system—more resources and more services. The need for more resources is satisfied either by obtaining more efficient use of existing resources, or by creating an illusion that more resources exist in the system.  A virtual memory is what its name indicates—it is an illusion of a memory that is larger than the real memory, i.e., RAM, of the computer system. A user or his application program sees only the virtual memory.  The kernel implements the illusion through a combination of hardware and software means. We refer to real memory simply as memory. We refer to the software component of virtual memory as a virtual memory manager.  The illusion of memory larger than the system’s memory crops up any time a process whose size exceeds the size of memory is initiated. The process is able to operate because it is kept in its entirety on a disk and only its required portions are loaded in memory at any time.  The basis of virtual memory is the noncontiguous memory allocation model described earlier in. The address space of each process is assumed to consist of portions called components. The portions can be loaded into nonadjacent areas of memory. Operating System: VIRTUAL MEMORY
  • 4. Virtual memory Basics Demand paging Page replacement policies Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 4 Virtual memory Basics  The address of each operand or instruction in the code of a process is a logical address of the form (compi, bytei).  The memory management unit (MMU) translates it into the address in memory where the operand or instruction actually resides. Use of the noncontiguous memory allocation model reduces memory fragmentation, since a free area of memory can be reused even if it is not large enough to hold the entire address space of a process. More user processes can be accommodated in memory this way, which benefits both users and the OS. Operating System: VIRTUAL MEMORY  The kernel carries this idea further—even processes that can fit in memory are not loaded fully into memory. This strategy reduces the amount of memory that is allocated to each process, thus further increasing the number of processes that can be in operation at the same time. Figure shows a schematic diagram of a virtual memory.
  • 5. Virtual memory Basics Demand paging Page replacement policies Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 5 Virtual memory Basics  The logical address space of the process shown consists of five components. Three of these components are presently in memory. Information about the memory areas where these components exist is maintained in a data structure of the virtual memory manager. This information is used by the MMU during address translation. When an instruction in the process refers to a data item or instruction that is not in memory, the component containing it is loaded from the disk. Occasionally, the virtual memory manager removes some components from memory to make room for other components.  The arrangement shown in Figure is a memory hierarchy as discussed earlier. The hierarchy consists of the system’s memory and a disk. Memory is fast, but small in size. The disk is slow, but has a much larger capacity.  The MMU and the virtual memory manager together manage the memory hierarchy, so that the current instruction in a process finds its operands in memory. We are now ready to define virtual memory.  Virtual Memory: A memory hierarchy, consisting of a computer system’s memory and a disk, that enables a process to operate with only some portions of its address space in memory. Operating System: VIRTUAL MEMORY
  • 6. Virtual memory Basics Demand paging Page replacement policies Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 6 Virtual memory Basics  Demand Loading of Process Components The virtual memory manager loads only one component of a process address space in memory to begin with—the component that contains the start address of the process, that is, address of the instruction with which its execution begins. It loads other components of the process only when they are needed. This technique is called demand loading. To keep the memory commitment to a process low, the virtual memory manager removes components of the process from memory from time to time. These components would be loaded back in memory when needed again. Performance of a process in virtual memory depends on the rate at which its components have to be loaded into memory. The virtual memory manager exploits the law of locality of reference to achieve a low rate of loading of process components. Operating System: VIRTUAL MEMORY
  • 7. Virtual memory Basics Demand paging Page replacement policies Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 7 Virtual memory Basics  Paging and Segmentation: Implementation of virtual memory differ in the manner in which the boundaries and sizes of address space components are determined. Table compares the two approaches. In paging, each component of an address space is called a page. All pages have identical size, which is a power of two. Page size is defined by the computer hardware and demarcation of pages in the address space of a process is performed implicitly by it. In segmentation, each component of an address space is called a segment. A programmer declares some significant logical entities (e.g., data structures or objects) in a process as segments. Operating System: VIRTUAL MEMORY
  • 8. Virtual memory Basics Demand paging Page replacement policies Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 8 Virtual memory Basics  Thus identification of components is performed by the programmer, and segments can have different sizes. This fundamental difference leads to different implications for efficient use of memory and for sharing of programs or data. Some systems use a hybrid segmentation-with- paging approach to obtain advantages of both the approaches.  In paging, each component of an address space is called a page. All pages have identical size, which is a power of two. Page size is defined by the computer hardware and demarcation of pages in the address space of a process is performed implicitly by it. In segmentation, each component of an address space is called a segment.  A programmer declares some significant logical entities (e.g., data structures or objects) in a process as segments. Thus identification of components is performed by the programmer, and segments can have different sizes. This fundamental difference leads to different implications for efficient use of memory and for sharing of programs or data. Some systems use a hybrid segmentation-with-paging approach to obtain advantages of both the approaches. Operating System: VIRTUAL MEMORY
  • 9. Virtual memory Basics Demand paging Page replacement policies Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 9 Virtual memory Basics Demand paging A process is considered to consist of pages, numbered from 0 onward. Each page is of size s bytes, where s is a power of 2. The memory of the computer system is considered to consist of page frames, where a page frame is a memory area that has the same size as a page. Page frames are numbered from 0 to #frames-1 where #frames is the number of page frames of memory. Accordingly, the physical address space consists of addresses from 0 to #frames × s - 1. At any moment, a page frame may be free, or it may contain a page of some process. Each logical address used in a process is considered to be a pair (pi, bi), where pi is a page number and bi is the byte number in pi, 0 ≤ bi < s. The effective memory address of a logical address (pi, bi) is computed as follows: Effective memory address of logical address (pi, bi) = start address of the page frame containing page pi + bi The size of a page is a power of 2, and so calculation of the effective address is performed through bit concatenation, which is much faster than addition Operating System: VIRTUAL MEMORY
  • 10. Virtual memory Basics Demand paging Page replacement policies Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 10 Virtual memory Basics Demand paging Figure is a schematic diagram of a virtual memory using paging in which page size is assumed to be 1 KB, where 1 KB = 1024 bytes. Three processes P1, P2 and P3, have some of their pages in memory. The memory contains 8 page frames numbered from 0 to 7. Memory allocation information for a process is stored in a page table. Each entry in the page table contains memory allocation information for one page of a process. It contains the page frame number where a page resides. Operating System: VIRTUAL MEMORY Process P2 has its pages 1 and 2 in memory. They occupy page frames 5 and 7 respectively. Process P1 has its pages 0 and 2 in page frames 4 and 1, while process P3 has its pages 1, 3 and 4 in page frames 0, 2 and 3, respectively. The free frames list contains a list of free page frames. Currently only page frame 6 is free. Process P2 is currently executing the instruction ‘Add ·· 2528’, so the MMU uses P2’s page table for address translation. The MMU views the operand address 2528 as the pair (2, 480) because 2528 = 2 × 1024 + 480. It now accesses the entry for page 2 in P2’s page table. This entry contains frame number 7, so the MMU forms the effective address 7 × 1024 + 480 according to Eq. (12.1), and uses it to make a memory access. In effect, byte 480 in page frame 7 is accessed.
  • 11. Virtual memory Basics Demand paging Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 11  A page replacement policy should replace a page that is not likely to be referenced in the immediate future. We evaluate the following three page replacement policies to see how well they fulfill this requirement. • Optimal page replacement policy • First-in, first-out (FIFO) page replacement policy • Least recently used (LRU) page replacement policy Page replacement policies Operating System: VIRTUAL MEMORY Optimal Page Replacement: Optimal page replacement means making page replacement decisions in such a manner that the total number of page faults during operation of a process is the minimum possible; i.e., no other sequence of page replacement decisions can lead to a smaller number of page faults. To achieve optimal page replacement, at each page fault, the page replacement policy would have to consider all alternative page replacement decisions, analyze their implications for future page faults, and select the best alternative. Of course, such a policy is infeasible in reality: the virtual memory manager does not have knowledge of the future behavior of a process. As an analytical tool, however, this policy provides a useful comparison in hindsight for the performance of other page replacement policies. Although optimal page replacement might seem to require excessive analysis, Belady (1966) showed that it is equivalent to the following simple rule: At a page fault, replace the page whose next reference is farthest in the page reference string.
  • 12. Virtual memory Basics Demand paging Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 12 Page replacement policies Operating System: VIRTUAL MEMORY FIFO Page Replacement At every page fault, the FIFO page replacement policy replaces the page that was loaded into memory earlier than any other page of the process. To facilitate FIFO page replacement, the virtual memory manager records the time of loading of a page in the ref info field of its page table entry. When a page fault occurs, this information is used to determine pearliest, the page that was loaded earlier than any other page of the process. This is the page that will be replaced with the page whose reference led to the page fault. LRU Page Replacement: The LRU policy uses the law of locality of reference as the basis for its replacement decisions. Its operation can be described as follows: At every page fault the least recently used (LRU) page is replaced by the required page. The page table entry of a page records the time when the page was last referenced. This information is initialized when a page is loaded, and it is updated every time the page is referenced. When a page fault occurs, this information is used to locate the page pLRU whose last reference is earlier than that of every other page. This page is replaced with the page whose reference led to the page fault.
  • 13. Prepared by Prof. Anand H. D., Dept. of ECE, Dr. AIT, Bengaluru-56 13 Reference 1. D.M.Dhamdhare, “Operating Systems”, Second Edition, TMH, 2008 Operating System: VIRTUAL MEMORY Virtual memory Basics Demand paging Page replacement policies
  • 14. 14 Prof. Anand H. D. M. Tech. (PhD.) Assistant Professor, Department of Electronics & Communication Engineering Dr. Ambedkar Institute of Technology, Bengaluru-56 Email: anandhdece@dr-ait.org Phone: 9844518832