SlideShare a Scribd company logo
1 of 28
VirtualVirtual
MemoryMemory
Mr. SUBHASIS DASH
SCHOLE OF COMPUTER
ENGINEERING.
KIIT UNIVERSITY
BHUBANESWAR
BackgroundBackground
Virtual memory – separation of user logical memory from
physical memory.
Only part of the program needs to be in memory for execution
Logical address space can therefore be much larger than
physical address space
Allows address spaces to be shared by several processes
Allows for more efficient process creation
Virtual memory can be implemented via:
Demand paging
Demand segmentation
Virtual Memory That is Larger Than PhysicalVirtual Memory That is Larger Than Physical
MemoryMemory
⇒
Demand PagingDemand Paging
Bring a page into memory only when it is needed
Less I/O needed
Less memory needed
Faster response
More users
Page is needed ⇒ reference to it
invalid reference ⇒ abort
not-in-memory ⇒ bring to memory
Lazy swapper – never swaps a page into memory unless page
will be needed
Swapper that deals with pages is a pager
Transfer of a Paged Memory to Contiguous DiskTransfer of a Paged Memory to Contiguous Disk
SpaceSpace
Valid-Invalid BitValid-Invalid Bit
Valid / invalid bit is used to know which page is legal & needed.
With each page table entry a valid–invalid bit is associated
(v ⇒ Legal page & in-memory, i ⇒ Illegal page & not-in-memory)
Initially valid–invalid bit is set to i on all entries then it has to
updated.
Example of a page table snapshot:
During address translation, if valid–invalid bit in page table entry
is I ⇒ page fault
v
v
v
v
i
i
i
….
Frame # valid-invalid bit
page table
Page Table When Some Pages Are Not in MainPage Table When Some Pages Are Not in Main
MemoryMemory
Backing
storage
Page FaultPage Fault
If the process is available on main memory in terms of pages
then a legal page (V)access is possible & execution starts.
If there is a reference to a page for access & the page is not
available on main memory then it is an illegal page (I) which will
be trap to operating system: PAGE FAULT
1. Operating system looks at another table to decide:
Invalid reference ⇒ abort
Just not in memory
1. Get empty frame on main memory to load the illegal page.
2. Swap page into frame.
3. Reset tables entries [ I bit converts to V ]
4. Set validation bit = v
5. Restart the instruction that caused the page fault
Steps in Handling a Page FaultSteps in Handling a Page Fault
Page Fault Service TimePage Fault Service Time
1. Trap to the operating system.
2. Save the user register & process state.
3. Determine the interrupt was a page fault.
4. Determine the page location on disk.
5. Issue a read from disk to free frame ( device queue, disk latency time
& page transfer time )
6. While waiting allocate the CPU to some other user.
7. Interrupt from disk (I/O completion).
8. Save the process state for the other process.
9. Determine that the interrupt was from disk.
10. Correct the page table.
11. Wait for CPU to resume back to the same process.
12. Restore the user register, process state & new page table then
resume the interrupted instruction.
Performance of Demand PagingPerformance of Demand Paging
Page Fault Rate 0 ≤ p ≤ 1
if p = 0 no page faults
if p = 1, every reference is a fault
Effective Access Time (EAT)
EAT = (1 - p) x ma + p x page fault service time
EAT = (1 – p) x memory access
+ p x (page fault overhead + swap page out + swap page in +
restart overhead )
What happens if there is no free frame?What happens if there is no free frame?
When page fault service finds the desired page on disk and wants
to transfer it to a free frame on main memory then there may be
two possibilities 
Free frame found then
Free frame not found then
Process may abort or Process may swap.
Intended to have dynamic swapping instead of the whole process
to swap with another process.
Page replacement – find some free frame/page in memory, but
not really in use, swap it out, so that desired page can swap in.
Page replacement algorithm
performance – want an algorithm which will result in minimum
number of page faults
Same page may be brought into memory several times
Need For Page ReplacementNeed For Page Replacement
Page ReplacementPage Replacement
Prevent over-allocation of memory by modifying page-fault
service routine to include page replacement
Use modify (dirty) bit to reduce overhead of page transfers
– only modified pages are written to disk
Page replacement completes separation between logical
memory and physical memory – large virtual memory can be
provided on a smaller physical memory
Basic Page ReplacementBasic Page Replacement
1. Find the location of the desired page on disk
2. Find a free frame:
A. If there is a free frame, use it
B. If there is no free frame, use a page replacement algorithm to
select a victim frame
C. Write the victim page to the disk; change the page table and
frame table.
3. Bring the desired page into the (newly) free frame; update the
page and frame table.
4. Restart the user process.
For each case where no free frames available effectively doubles
the page fault service time & increase the EAT.
Solution  Maintain a MODIFY BIT.
Modify BitModify Bit
To reduce the page fault service time use a modify bit which is
associated with each page.
If modify bit is set to 1 then
Page has been modified, write the page to disk, so that it can
be modified over main memory.
If modify bit is set to 0 then
Page has not been modified, since it was read into main
memory.
Victim Page Selection
Leads to lowest page fault
Reference string
Free frame increases  the page fault decrease.
Page ReplacementPage Replacement
Page Replacement AlgorithmsPage Replacement Algorithms
Want lowest page-fault rate
Evaluate algorithm by running it on a particular string of
memory references (reference string) and computing the
number of page faults on that string
First-In-First-Out (FIFO) AlgorithmFirst-In-First-Out (FIFO) Algorithm
Replacement is depends upon the arrival time of a page to
memory.
A page is replaced when it is oldest (in the ascending order
of page arrival time to memory).
As it is a FIFO queue no need to record the arrival time of a
page & the page at the head of the queue is replaced.
Performance is not good always
When a active page is replaced to bring a new page, then a
page fault occurs immediately to retrieve the active page.
To get the active page back some other page has to be
replaced. Hence the page fault increases.
FIFO Page ReplacementFIFO Page Replacement
H
I
T
TWO
HITS
TWO
HITS
15 PAGE FAULTS
Problem with FIFO AlgorithmProblem with FIFO Algorithm
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
3 frames (3 pages can be in memory at a time per process)
4 frames
Belady’s Anomaly: more frames ⇒ more page faults
1
2
3
1
2
3
4
1
2
5
3
4
9 page faults
1
2
3
1
2
3
5
1
2
4
5
10 page faults44 3
UNEXPECTED
Page fault
increases
Optimal AlgorithmOptimal Algorithm
To recover from belady’s anomaly problem : Use Optimal
page replacement algorithm
Replace the page that will not be used for longest period of time.
This guarantees lowest possible page fault rate for a fixed
number of frames.
Example :
First we found 3 page faults to fill the frames.
Then replace page 7 with page 2 because it will not needed upto the
18th
place in reference string.
Finally there are 09 page faults.
Hence it is better than FIFO algorithm (15 page Faults).
Optimal Page ReplacementOptimal Page Replacement
H
I
T
H
I
T
TWO
HITS
TWO
HITS
THRE
E
HITS
TWO
HITS
09 PAGE FAULTS
Difficulty with Optimal AlgorithmDifficulty with Optimal Algorithm
Replace page that will not be used for longest period of time
4 frames example
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
Used for measuring how well your algorithm performs.
It always needs future knowledge of reference
string.
1
2
3
4
6 page faults
4 5
Least Recently Used (LRU)Least Recently Used (LRU)
AlgorithmAlgorithm
LRU algorithm lies between FIFO & Optimal algorithm ( in
terms of page faults).
FIFO : time when page brought into memory.
OPTIMAL : time when a page will used.
LRU : Use the recent past as an approximation of near
future (so it cant be replaced), then we will replace that
page which has not been used for longest period of time.
Hence it is least recently used algorithm.
Example :
Up to 5th
page fault it is same as optimal algorithm.
When page 4 occur LRU chose page 2 for replacement.
Here we find only 12 page faults.
LRU Page ReplacementLRU Page Replacement
H
I
T
H
I
T
TWO
HITS
H
I
T
H
I
T
TWO
HITS
12 PAGE
FAULTS
Least Recently Used (LRU)Least Recently Used (LRU)
AlgorithmAlgorithm
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
Counter implementation
Every page entry has a counter; every time page is referenced
through this entry, copy the clock into the counter
When a page needs to be changed, look at the counters to
determine which are to change
5
2
4
3
1
2
3
4
1
2
5
4
1
2
5
3
1
2
4
3
End of Chapter 9End of Chapter 9

More Related Content

What's hot

Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithmssangrampatil81
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt completeKalai Selvi
 
Page replacement
Page replacementPage replacement
Page replacementsashi799
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithmsPiyush Rochwani
 
40 demand paging
40 demand paging40 demand paging
40 demand pagingmyrajendra
 
Operating system 37 demand paging
Operating system 37 demand pagingOperating system 37 demand paging
Operating system 37 demand pagingVaibhav Khanna
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Managementprimeteacher32
 
Virtual memoryfinal
Virtual memoryfinalVirtual memoryfinal
Virtual memoryfinalmarangburu42
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithmMuhammad Mansoor Ul Haq
 
Computer architecture page replacement algorithms
Computer architecture page replacement algorithmsComputer architecture page replacement algorithms
Computer architecture page replacement algorithmsMazin Alwaaly
 
42 lru optimal
42 lru optimal42 lru optimal
42 lru optimalmyrajendra
 
Lect 27 28_29_30_virtual_memory
Lect 27 28_29_30_virtual_memoryLect 27 28_29_30_virtual_memory
Lect 27 28_29_30_virtual_memorySoumendu Sarkar
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory ManagementRahul Jamwal
 

What's hot (17)

Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
OSCh10
OSCh10OSCh10
OSCh10
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
 
Page replacement
Page replacementPage replacement
Page replacement
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
40 demand paging
40 demand paging40 demand paging
40 demand paging
 
Operating system 37 demand paging
Operating system 37 demand pagingOperating system 37 demand paging
Operating system 37 demand paging
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Management
 
Virtual memoryfinal
Virtual memoryfinalVirtual memoryfinal
Virtual memoryfinal
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithm
 
Computer architecture page replacement algorithms
Computer architecture page replacement algorithmsComputer architecture page replacement algorithms
Computer architecture page replacement algorithms
 
42 lru optimal
42 lru optimal42 lru optimal
42 lru optimal
 
Page replacement alg
Page replacement algPage replacement alg
Page replacement alg
 
Page replacement
Page replacementPage replacement
Page replacement
 
Lect 27 28_29_30_virtual_memory
Lect 27 28_29_30_virtual_memoryLect 27 28_29_30_virtual_memory
Lect 27 28_29_30_virtual_memory
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Management
 

Similar to Operating System

Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryWayne Jones Jnr
 
Mca ii os u-4 memory management
Mca  ii  os u-4 memory managementMca  ii  os u-4 memory management
Mca ii os u-4 memory managementRai University
 
Ch10 OS
Ch10 OSCh10 OS
Ch10 OSC.U
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
virtual memory Operating system
virtual memory Operating system virtual memory Operating system
virtual memory Operating system Shaheen kousar
 
Virtual memory This is the operating system ppt.ppt
Virtual memory This is the operating system ppt.pptVirtual memory This is the operating system ppt.ppt
Virtual memory This is the operating system ppt.pptry54321288
 
Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858marangburu42
 
Lecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptxLecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptxAmanuelmergia
 
Virtualmemorypre final-formatting-161019022904
Virtualmemorypre final-formatting-161019022904Virtualmemorypre final-formatting-161019022904
Virtualmemorypre final-formatting-161019022904marangburu42
 
381 ccs chapter7_updated(1)
381 ccs chapter7_updated(1)381 ccs chapter7_updated(1)
381 ccs chapter7_updated(1)Rabie Masoud
 
Virtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdfVirtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdfHarika Pudugosula
 

Similar to Operating System (20)

Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 
Mca ii os u-4 memory management
Mca  ii  os u-4 memory managementMca  ii  os u-4 memory management
Mca ii os u-4 memory management
 
Ch10 OS
Ch10 OSCh10 OS
Ch10 OS
 
OS_Ch10
OS_Ch10OS_Ch10
OS_Ch10
 
CH09.pdf
CH09.pdfCH09.pdf
CH09.pdf
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
virtual memory Operating system
virtual memory Operating system virtual memory Operating system
virtual memory Operating system
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Virtual memory
Virtual memory Virtual memory
Virtual memory
 
Sucet os module_4_notes
Sucet os module_4_notesSucet os module_4_notes
Sucet os module_4_notes
 
Virtual Memory.pdf
Virtual Memory.pdfVirtual Memory.pdf
Virtual Memory.pdf
 
Distributed Operating System_3
Distributed Operating System_3Distributed Operating System_3
Distributed Operating System_3
 
Virtual memory This is the operating system ppt.ppt
Virtual memory This is the operating system ppt.pptVirtual memory This is the operating system ppt.ppt
Virtual memory This is the operating system ppt.ppt
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Module4
Module4Module4
Module4
 
Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858
 
Lecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptxLecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptx
 
Virtualmemorypre final-formatting-161019022904
Virtualmemorypre final-formatting-161019022904Virtualmemorypre final-formatting-161019022904
Virtualmemorypre final-formatting-161019022904
 
381 ccs chapter7_updated(1)
381 ccs chapter7_updated(1)381 ccs chapter7_updated(1)
381 ccs chapter7_updated(1)
 
Virtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdfVirtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdf
 

More from Subhasis Dash

Computer Organisation and Architecture
Computer Organisation and ArchitectureComputer Organisation and Architecture
Computer Organisation and ArchitectureSubhasis Dash
 
Computer Organisation and Architecture
Computer Organisation and ArchitectureComputer Organisation and Architecture
Computer Organisation and ArchitectureSubhasis Dash
 
Computer Organisation and Architecture
Computer Organisation and ArchitectureComputer Organisation and Architecture
Computer Organisation and ArchitectureSubhasis Dash
 
Computer Organisation and Architecture
Computer Organisation and ArchitectureComputer Organisation and Architecture
Computer Organisation and ArchitectureSubhasis Dash
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer ArchitectureSubhasis Dash
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer ArchitectureSubhasis Dash
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer ArchitectureSubhasis Dash
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer ArchitectureSubhasis Dash
 
Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Subhasis Dash
 

More from Subhasis Dash (17)

Operating System
Operating SystemOperating System
Operating System
 
Operating System
Operating SystemOperating System
Operating System
 
Operating System
Operating SystemOperating System
Operating System
 
Operating System
Operating SystemOperating System
Operating System
 
Operating System
Operating SystemOperating System
Operating System
 
Operating System
Operating SystemOperating System
Operating System
 
Operating System
Operating SystemOperating System
Operating System
 
Computer Organisation and Architecture
Computer Organisation and ArchitectureComputer Organisation and Architecture
Computer Organisation and Architecture
 
Computer Organisation and Architecture
Computer Organisation and ArchitectureComputer Organisation and Architecture
Computer Organisation and Architecture
 
Computer Organisation and Architecture
Computer Organisation and ArchitectureComputer Organisation and Architecture
Computer Organisation and Architecture
 
Computer Organisation and Architecture
Computer Organisation and ArchitectureComputer Organisation and Architecture
Computer Organisation and Architecture
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1) Computer Organisation & Architecture (chapter 1)
Computer Organisation & Architecture (chapter 1)
 
Motherboard
MotherboardMotherboard
Motherboard
 

Recently uploaded

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
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
 
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
 
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
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
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
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
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
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
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
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
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
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 

Recently uploaded (20)

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.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 )
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.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
 
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
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.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
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
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
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
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
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
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
 
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
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 

Operating System

  • 1. VirtualVirtual MemoryMemory Mr. SUBHASIS DASH SCHOLE OF COMPUTER ENGINEERING. KIIT UNIVERSITY BHUBANESWAR
  • 2. BackgroundBackground Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution Logical address space can therefore be much larger than physical address space Allows address spaces to be shared by several processes Allows for more efficient process creation Virtual memory can be implemented via: Demand paging Demand segmentation
  • 3. Virtual Memory That is Larger Than PhysicalVirtual Memory That is Larger Than Physical MemoryMemory ⇒
  • 4. Demand PagingDemand Paging Bring a page into memory only when it is needed Less I/O needed Less memory needed Faster response More users Page is needed ⇒ reference to it invalid reference ⇒ abort not-in-memory ⇒ bring to memory Lazy swapper – never swaps a page into memory unless page will be needed Swapper that deals with pages is a pager
  • 5. Transfer of a Paged Memory to Contiguous DiskTransfer of a Paged Memory to Contiguous Disk SpaceSpace
  • 6. Valid-Invalid BitValid-Invalid Bit Valid / invalid bit is used to know which page is legal & needed. With each page table entry a valid–invalid bit is associated (v ⇒ Legal page & in-memory, i ⇒ Illegal page & not-in-memory) Initially valid–invalid bit is set to i on all entries then it has to updated. Example of a page table snapshot: During address translation, if valid–invalid bit in page table entry is I ⇒ page fault v v v v i i i …. Frame # valid-invalid bit page table
  • 7. Page Table When Some Pages Are Not in MainPage Table When Some Pages Are Not in Main MemoryMemory Backing storage
  • 8. Page FaultPage Fault If the process is available on main memory in terms of pages then a legal page (V)access is possible & execution starts. If there is a reference to a page for access & the page is not available on main memory then it is an illegal page (I) which will be trap to operating system: PAGE FAULT 1. Operating system looks at another table to decide: Invalid reference ⇒ abort Just not in memory 1. Get empty frame on main memory to load the illegal page. 2. Swap page into frame. 3. Reset tables entries [ I bit converts to V ] 4. Set validation bit = v 5. Restart the instruction that caused the page fault
  • 9. Steps in Handling a Page FaultSteps in Handling a Page Fault
  • 10. Page Fault Service TimePage Fault Service Time 1. Trap to the operating system. 2. Save the user register & process state. 3. Determine the interrupt was a page fault. 4. Determine the page location on disk. 5. Issue a read from disk to free frame ( device queue, disk latency time & page transfer time ) 6. While waiting allocate the CPU to some other user. 7. Interrupt from disk (I/O completion). 8. Save the process state for the other process. 9. Determine that the interrupt was from disk. 10. Correct the page table. 11. Wait for CPU to resume back to the same process. 12. Restore the user register, process state & new page table then resume the interrupted instruction.
  • 11. Performance of Demand PagingPerformance of Demand Paging Page Fault Rate 0 ≤ p ≤ 1 if p = 0 no page faults if p = 1, every reference is a fault Effective Access Time (EAT) EAT = (1 - p) x ma + p x page fault service time EAT = (1 – p) x memory access + p x (page fault overhead + swap page out + swap page in + restart overhead )
  • 12. What happens if there is no free frame?What happens if there is no free frame? When page fault service finds the desired page on disk and wants to transfer it to a free frame on main memory then there may be two possibilities  Free frame found then Free frame not found then Process may abort or Process may swap. Intended to have dynamic swapping instead of the whole process to swap with another process. Page replacement – find some free frame/page in memory, but not really in use, swap it out, so that desired page can swap in. Page replacement algorithm performance – want an algorithm which will result in minimum number of page faults Same page may be brought into memory several times
  • 13. Need For Page ReplacementNeed For Page Replacement
  • 14. Page ReplacementPage Replacement Prevent over-allocation of memory by modifying page-fault service routine to include page replacement Use modify (dirty) bit to reduce overhead of page transfers – only modified pages are written to disk Page replacement completes separation between logical memory and physical memory – large virtual memory can be provided on a smaller physical memory
  • 15. Basic Page ReplacementBasic Page Replacement 1. Find the location of the desired page on disk 2. Find a free frame: A. If there is a free frame, use it B. If there is no free frame, use a page replacement algorithm to select a victim frame C. Write the victim page to the disk; change the page table and frame table. 3. Bring the desired page into the (newly) free frame; update the page and frame table. 4. Restart the user process. For each case where no free frames available effectively doubles the page fault service time & increase the EAT. Solution  Maintain a MODIFY BIT.
  • 16. Modify BitModify Bit To reduce the page fault service time use a modify bit which is associated with each page. If modify bit is set to 1 then Page has been modified, write the page to disk, so that it can be modified over main memory. If modify bit is set to 0 then Page has not been modified, since it was read into main memory. Victim Page Selection Leads to lowest page fault Reference string Free frame increases  the page fault decrease.
  • 18. Page Replacement AlgorithmsPage Replacement Algorithms Want lowest page-fault rate Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string
  • 19. First-In-First-Out (FIFO) AlgorithmFirst-In-First-Out (FIFO) Algorithm Replacement is depends upon the arrival time of a page to memory. A page is replaced when it is oldest (in the ascending order of page arrival time to memory). As it is a FIFO queue no need to record the arrival time of a page & the page at the head of the queue is replaced. Performance is not good always When a active page is replaced to bring a new page, then a page fault occurs immediately to retrieve the active page. To get the active page back some other page has to be replaced. Hence the page fault increases.
  • 20. FIFO Page ReplacementFIFO Page Replacement H I T TWO HITS TWO HITS 15 PAGE FAULTS
  • 21. Problem with FIFO AlgorithmProblem with FIFO Algorithm Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 3 frames (3 pages can be in memory at a time per process) 4 frames Belady’s Anomaly: more frames ⇒ more page faults 1 2 3 1 2 3 4 1 2 5 3 4 9 page faults 1 2 3 1 2 3 5 1 2 4 5 10 page faults44 3 UNEXPECTED Page fault increases
  • 22. Optimal AlgorithmOptimal Algorithm To recover from belady’s anomaly problem : Use Optimal page replacement algorithm Replace the page that will not be used for longest period of time. This guarantees lowest possible page fault rate for a fixed number of frames. Example : First we found 3 page faults to fill the frames. Then replace page 7 with page 2 because it will not needed upto the 18th place in reference string. Finally there are 09 page faults. Hence it is better than FIFO algorithm (15 page Faults).
  • 23. Optimal Page ReplacementOptimal Page Replacement H I T H I T TWO HITS TWO HITS THRE E HITS TWO HITS 09 PAGE FAULTS
  • 24. Difficulty with Optimal AlgorithmDifficulty with Optimal Algorithm Replace page that will not be used for longest period of time 4 frames example 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 Used for measuring how well your algorithm performs. It always needs future knowledge of reference string. 1 2 3 4 6 page faults 4 5
  • 25. Least Recently Used (LRU)Least Recently Used (LRU) AlgorithmAlgorithm LRU algorithm lies between FIFO & Optimal algorithm ( in terms of page faults). FIFO : time when page brought into memory. OPTIMAL : time when a page will used. LRU : Use the recent past as an approximation of near future (so it cant be replaced), then we will replace that page which has not been used for longest period of time. Hence it is least recently used algorithm. Example : Up to 5th page fault it is same as optimal algorithm. When page 4 occur LRU chose page 2 for replacement. Here we find only 12 page faults.
  • 26. LRU Page ReplacementLRU Page Replacement H I T H I T TWO HITS H I T H I T TWO HITS 12 PAGE FAULTS
  • 27. Least Recently Used (LRU)Least Recently Used (LRU) AlgorithmAlgorithm Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 Counter implementation Every page entry has a counter; every time page is referenced through this entry, copy the clock into the counter When a page needs to be changed, look at the counters to determine which are to change 5 2 4 3 1 2 3 4 1 2 5 4 1 2 5 3 1 2 4 3
  • 28. End of Chapter 9End of Chapter 9