SlideShare uma empresa Scribd logo
1 de 9
Abir Naskar | 10MA60R21 | March 26, 2014
Virtual Memory
COMPUTER SCIENCE AND DATA PROCESSING
PAGE 1
Abstract
Virtual memory is the concept by which we can use secondary storage as an extension of primary
storage, by using paging concept. This memory management technique is implemented by using
hardware and software. In this report I am going to present that how virtual memory helps us to
make computer multitasking, and how to translate the virtual address to physical address and store
them in main memory. How to handle fault and replace page. The basic structure of page table.
And the basic difference between cache memory and virtual memory. And lastly some advantage
and disadvantages of virtual memory.
Introduction
Virtual Memory
Virtual (or logical) memory is a concept that, when implemented by a computer and its operating
system, allows programmers to use a very large range of memory or storage addresses for stored
data. The computing system maps the programmer's virtual addresses to real hardware storage
addresses. Usually, the programmer is freed from having to be concerned about the availability of
data storage.
In addition to managing the mapping of virtual storage addresses to real storage addresses, a
computer implementing virtual memory or storage also manages storage swapping between active
storage (RAM) and hard disk or other high volume storage devices. Data is read in units called
"pages" of sizes ranging from a thousand bytes (actually 1,024 decimal bytes) up to several
megabytes in size. This reduces the amount of physical storage access that is required and speeds
up overall system performance.
Cache Memory
A small amount of high-speed memory residing on or close to the CPU is called Cache Memory.
Cache memory supplies the processor with the most frequently requested data and instructions.
Level 1 cache (primary cache) is the cache closest to the processor. Level 2 cache (secondary cache)
is the cache second closest to the processor and is usually on the motherboard.
Cache memory helps to alleviate the gap between the speed of a CPU's megahertz rating and the
ability of RAM to respond and deliver data. It reduces the frequency that the CPU must wait for
data from the main memory.
PAGE 2
Memory Hierarchy
The term memory hierarchy is used in computer architecture when discussing performance issues
in computer architectural design, algorithm predictions, and the lower level programming
constructs such as involving locality of reference. This distinguish each level of hierarchy by access
time or response time. The faster memory costs higher.
Typical memory hierarchy is:
CPU registers (8-256 registers): speed is near about 500 ps.
L1 cache (64KB): speed is less than 1 ns.
L2 cache (256MB): speed is 3-10 ns.
L3 cache (2MB – 4MB): speed is 10-20 ns.
RAM/main memory (4 - 16GB): speed is 50-100 ns.
Disk storage (4 - 16TB): speed is 5-10 ms.
Cache and Virtual memory
Cache Memory Virtual Memory
Is a hardware or processor. Is simulated on hard drive maintained by OS.
Data reads in unit called “block”. Data reads in unit called “pages”.
Stores memory access by CPU. Storage swapping between active storage and
hard disk.
Reduces the frequency that the CPU must wait
for data from the main memory.
Reduces the amount of physical storage access
that is required.
Performance-wise faster. Performance-wise slower.
System with only physical memory
In early days when virtually memory is not used, the CPU directly generates the physical address.
For example it is used in, most of the Cray machine, early PC, nearly all embedded systems etc.
The problems then was to run multi-programming or multi-tasking process or time-sharing tasks.
The program size should be less than the size of the RAM.
PAGE 3
Figure 1: system with only physical memory
System with virtual memory
In present days we use virtual memory system is used. Here we have to go through from an
intermediate state which is known as address translation. That is CPU first generates virtual
address and before it mapped to main memory it have to go through a translation process where
hardware convert virtual address to physical address via an OS managed look-up table which is
called page table. Page table has provision to keeping information about main memory address as
well as disk memory address. It use a valid bit to detect where the location is.
In the modern PCs, workstations, servers it is used.
PAGE 4
Figure 2: system with virtual memory
Paging
In computer science Paging is a Memory Management technique by which computer can store and
retrieve data from secondary storage for the use of main memory. Paging is an important part of
virtual memory implementation in Operating Systems, allowing them to use the disk storage for
the data that does not fit into the physical RAM. The main functions of Paging are performed when
a program tries to access a page that are currently not in RAM. This situation is known as page
fault. The operating system must take control and handle the page fault, in a manner invisible to
the program. Therefore, the OS must
1. Determine the location of the data in secondary storage.
2. Obtain an empty page frame in RAM to use as a container for the data.
3. Load the requested data into the available page frame.
4. Update page table to show new data.
5. Return control to the program.
PAGE 5
Page Table
Page table is data structure used to store mapping between virtual address to physical address. It is
used to translate logical address to physical address. The entries of page table are address which
contains pointer to the location of the page in memory (RAM or disk), valid bit which says that the
page is in RAM or in disk, dirty bit which is set if the page is modified at least once, referenced bit
which is used if page has been referenced with either read or write, this bit used to support
software replacement policies. Another bit is protection bit or access right bit which is used to
restrict the access, for example, read only access, write only access, system only access etc.
Figure 3: page table
Address Mapping
Virtual address has two parts virtual page number and page offset. The number of pages
addressable to the virtual address is virtually unlimited where as the number of pages addressable
by the physical address is limited. CPU generates virtual address.
A virtual address has two parts, virtual page number and offset. Virtual page number is index into a
page table. Page table entry contains page frame number. Physical address will be then
concatenation of page frame number and offset.
PAGE 6
Figure 4: address mapping
In the above image p defines virtual page number, o is offset of the page, f is the page frame
number.
Page translation example:
assume a 32bit address space, and page size is 4KB (log2(4096) = 12bits)
for a process to address the full logical address space, need 20bit virtual page number and 12 bits
offset.
Let we want to transform the virtual address 0x12345678. And let the offset contains 0x678. If the
page table entry of 12345 contains 0x01000 then the physical address will be 0x01000678.
Page Fault
Page fault occurs when page is on disk rather than memory.
When page fault occurs then the OS is invoked to move page from disk to main memory.
At the same time current process is suspended and other can resume. And OS has full control over
placement.
When a process is created, the OS creates space for all the pages of a process in the disk. This disk
space is called swap space. It also creates a data structure to record where each virtual page is
stored in the disk. The data structure may be part of the page table or separate. The OS also creates
a data structure that tracks which processes and which virtual addresses use each physical page. If
all pages in main memory are in use, the OS must choose a page to replace based on the past
history. The replaced pages are written to the swap space of the disk.
PAGE 7
Figure 5: before page fault Figure 6: after page fault
Page Replacement
When a fault occurs, the OS loads the faulted page from disk into a page of memory.
At some point, the process has used all of the page frames it is allowed to use.
When this happens, the OS must replace page for each page faulted in. That is, it must select a
page to throw out of primary memory to make room.
There are several page replacement algorithms, like FIFO, LRU (least recent used), Least
Frequently Used, optimal or minimum used etc.
the goal of the page replacement is to reduce the fault rate by selecting the best victim page to
remove.
Example
Let us use here LRU (least recently used technique).
Say we have the page reference string is, 1 2 3 4 2 1 5 6 2 1 2 3 7 6
assuming there is 4 page frame available. Then the procedure will be as follows.
Frame 1 1* 1* 1* 1* 1* 1 1 1 1* 1 1 1 1* 6
Frame 2 2 2 2 2 2 2 2* 2 2 2 2 2 2*
Frame 3 3 3 3 3* 5 5 5 5* 5* 3 3 3
Frame 4 4 4 4 4* 6 6 6 6 6* 7 7
faults Y Y Y Y N N Y Y N N N Y Y Y
PAGE 8
Advantage & Disadvantage
 We can run more applications at once.
 We can run larger applications with less real RAM.
 We have large memory in disk that is larger virtual memory.
 More efficient use of memory in this technique.
 There is no limit or degree of multiprogramming.
- Applications run slower.
- It takes more time to switch between applications.
- Less hard drive space for your use.
References
• Stallings W. (2006): “Operating Systems: Internals and Design Principles (7
th
Edition)”.
Prentice Hall.
• Tanenbaum A. S. (2013): “Modern Operating System (3
rd
edition)”, Pearson Education,
pp.175-247.
• Cragon, Harvey G. (1996). Memory Systems and Pipelined Processors. Jones and Bartlett
Publishers. ISBN 0-86720-474-5.
• Hannessy J. L, Patterson D. A. (2012). Computer Architecture a quantitative approach
.Elsevier. ISBN 978-0-12-383872-8.
• URL: http://windows.microsoft.com/en-us/windows/what-is-virtual-
memory#1TC=windows-7
• URL: http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Memory/virtual.htm

Mais conteúdo relacionado

Mais procurados

Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryWayne Jones Jnr
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAnuj Modi
 
Memory management
Memory managementMemory management
Memory managementcpjcollege
 
Cache memory ppt
Cache memory ppt  Cache memory ppt
Cache memory ppt Arpita Naik
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memoryvampugani
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSvampugani
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management Shashank Asthana
 
Virtual memory presentation
Virtual memory presentationVirtual memory presentation
Virtual memory presentationRanjeet Kumar
 
Operating Systems: Virtual Memory
Operating Systems: Virtual MemoryOperating Systems: Virtual Memory
Operating Systems: Virtual MemoryDamian T. Gordon
 
Operating system paging and segmentation
Operating system paging and segmentationOperating system paging and segmentation
Operating system paging and segmentationhamza haseeb
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memorysgpraju
 
Chapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage SystemsChapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage SystemsWayne Jones Jnr
 
Implementation of page table
Implementation of page tableImplementation of page table
Implementation of page tableguestff64339
 

Mais procurados (20)

Virtual memory
Virtual memory Virtual memory
Virtual memory
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Memory management
Memory managementMemory management
Memory management
 
Cache memory ppt
Cache memory ppt  Cache memory ppt
Cache memory ppt
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Virtual memory ppt
Virtual memory pptVirtual memory ppt
Virtual memory ppt
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 
Memory management
Memory managementMemory management
Memory management
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
 
Virtual memory presentation
Virtual memory presentationVirtual memory presentation
Virtual memory presentation
 
Operating Systems: Virtual Memory
Operating Systems: Virtual MemoryOperating Systems: Virtual Memory
Operating Systems: Virtual Memory
 
Operating system paging and segmentation
Operating system paging and segmentationOperating system paging and segmentation
Operating system paging and segmentation
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
Chapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage SystemsChapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage Systems
 
Implementation of page table
Implementation of page tableImplementation of page table
Implementation of page table
 

Destaque

Ch10: Virtual Memory
Ch10: Virtual MemoryCh10: Virtual Memory
Ch10: Virtual MemoryAhmar Hashmi
 
Virtual Memory (Making a Process)
Virtual Memory (Making a Process)Virtual Memory (Making a Process)
Virtual Memory (Making a Process)David Evans
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAsif Iqbal
 
basics of virtual memory
basics of virtual memorybasics of virtual memory
basics of virtual memoryAdarsh Patel
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryMohd Arif
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryvatsaanadi
 
39 virtual memory
39 virtual memory39 virtual memory
39 virtual memorymyrajendra
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryrapunzel08
 
Operating Systems - Virtual Memory
Operating Systems - Virtual MemoryOperating Systems - Virtual Memory
Operating Systems - Virtual MemoryEmery Berger
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managmentSantu Kumar
 
Virtual Memory vs Cache Memory
Virtual Memory vs Cache MemoryVirtual Memory vs Cache Memory
Virtual Memory vs Cache MemoryAshik Iqbal
 
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 and Paging
Virtual Memory and PagingVirtual Memory and Paging
Virtual Memory and PagingEmery Berger
 

Destaque (20)

Ch10: Virtual Memory
Ch10: Virtual MemoryCh10: Virtual Memory
Ch10: Virtual Memory
 
Ch09
Ch09Ch09
Ch09
 
Os8
Os8Os8
Os8
 
Virtual Memory (Making a Process)
Virtual Memory (Making a Process)Virtual Memory (Making a Process)
Virtual Memory (Making a Process)
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
basics of virtual memory
basics of virtual memorybasics of virtual memory
basics of virtual memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Vm
VmVm
Vm
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
39 virtual memory
39 virtual memory39 virtual memory
39 virtual memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
virtual memory
virtual memoryvirtual memory
virtual memory
 
Operating Systems - Virtual Memory
Operating Systems - Virtual MemoryOperating Systems - Virtual Memory
Operating Systems - Virtual Memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managment
 
Virtual Memory vs Cache Memory
Virtual Memory vs Cache MemoryVirtual Memory vs Cache Memory
Virtual Memory vs Cache Memory
 
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 and Paging
Virtual Memory and PagingVirtual Memory and Paging
Virtual Memory and Paging
 
VIRTUAL MEMORY
VIRTUAL MEMORYVIRTUAL MEMORY
VIRTUAL MEMORY
 

Semelhante a virtual memory

Semelhante a virtual memory (20)

Paging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory managementPaging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory management
 
Os unit 2
Os unit 2Os unit 2
Os unit 2
 
virtual memory - Computer operating system
virtual memory - Computer operating systemvirtual memory - Computer operating system
virtual memory - Computer operating system
 
Abhaycavirtual memory and the pagehit.pptx
Abhaycavirtual memory and the pagehit.pptxAbhaycavirtual memory and the pagehit.pptx
Abhaycavirtual memory and the pagehit.pptx
 
CH09.pdf
CH09.pdfCH09.pdf
CH09.pdf
 
Memory virtualization
Memory virtualizationMemory virtualization
Memory virtualization
 
UNIT-2 OS.pptx
UNIT-2 OS.pptxUNIT-2 OS.pptx
UNIT-2 OS.pptx
 
Virtual memory pre-final-formatting
Virtual memory pre-final-formattingVirtual memory pre-final-formatting
Virtual memory pre-final-formatting
 
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
 
Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858
 
Virtual memoryfinal
Virtual memoryfinalVirtual memoryfinal
Virtual memoryfinal
 
Memory management ppt coa
Memory management ppt coaMemory management ppt coa
Memory management ppt coa
 
Unit 5-lecture-2
Unit 5-lecture-2Unit 5-lecture-2
Unit 5-lecture-2
 
unit5_os (1).pptx
unit5_os (1).pptxunit5_os (1).pptx
unit5_os (1).pptx
 
VirutualMemory.docx
VirutualMemory.docxVirutualMemory.docx
VirutualMemory.docx
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
OS_Ch9
OS_Ch9OS_Ch9
OS_Ch9
 
OSCh9
OSCh9OSCh9
OSCh9
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
 
Power Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.pptPower Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.ppt
 

Último

Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 

Último (20)

Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

virtual memory

  • 1. Abir Naskar | 10MA60R21 | March 26, 2014 Virtual Memory COMPUTER SCIENCE AND DATA PROCESSING
  • 2. PAGE 1 Abstract Virtual memory is the concept by which we can use secondary storage as an extension of primary storage, by using paging concept. This memory management technique is implemented by using hardware and software. In this report I am going to present that how virtual memory helps us to make computer multitasking, and how to translate the virtual address to physical address and store them in main memory. How to handle fault and replace page. The basic structure of page table. And the basic difference between cache memory and virtual memory. And lastly some advantage and disadvantages of virtual memory. Introduction Virtual Memory Virtual (or logical) memory is a concept that, when implemented by a computer and its operating system, allows programmers to use a very large range of memory or storage addresses for stored data. The computing system maps the programmer's virtual addresses to real hardware storage addresses. Usually, the programmer is freed from having to be concerned about the availability of data storage. In addition to managing the mapping of virtual storage addresses to real storage addresses, a computer implementing virtual memory or storage also manages storage swapping between active storage (RAM) and hard disk or other high volume storage devices. Data is read in units called "pages" of sizes ranging from a thousand bytes (actually 1,024 decimal bytes) up to several megabytes in size. This reduces the amount of physical storage access that is required and speeds up overall system performance. Cache Memory A small amount of high-speed memory residing on or close to the CPU is called Cache Memory. Cache memory supplies the processor with the most frequently requested data and instructions. Level 1 cache (primary cache) is the cache closest to the processor. Level 2 cache (secondary cache) is the cache second closest to the processor and is usually on the motherboard. Cache memory helps to alleviate the gap between the speed of a CPU's megahertz rating and the ability of RAM to respond and deliver data. It reduces the frequency that the CPU must wait for data from the main memory.
  • 3. PAGE 2 Memory Hierarchy The term memory hierarchy is used in computer architecture when discussing performance issues in computer architectural design, algorithm predictions, and the lower level programming constructs such as involving locality of reference. This distinguish each level of hierarchy by access time or response time. The faster memory costs higher. Typical memory hierarchy is: CPU registers (8-256 registers): speed is near about 500 ps. L1 cache (64KB): speed is less than 1 ns. L2 cache (256MB): speed is 3-10 ns. L3 cache (2MB – 4MB): speed is 10-20 ns. RAM/main memory (4 - 16GB): speed is 50-100 ns. Disk storage (4 - 16TB): speed is 5-10 ms. Cache and Virtual memory Cache Memory Virtual Memory Is a hardware or processor. Is simulated on hard drive maintained by OS. Data reads in unit called “block”. Data reads in unit called “pages”. Stores memory access by CPU. Storage swapping between active storage and hard disk. Reduces the frequency that the CPU must wait for data from the main memory. Reduces the amount of physical storage access that is required. Performance-wise faster. Performance-wise slower. System with only physical memory In early days when virtually memory is not used, the CPU directly generates the physical address. For example it is used in, most of the Cray machine, early PC, nearly all embedded systems etc. The problems then was to run multi-programming or multi-tasking process or time-sharing tasks. The program size should be less than the size of the RAM.
  • 4. PAGE 3 Figure 1: system with only physical memory System with virtual memory In present days we use virtual memory system is used. Here we have to go through from an intermediate state which is known as address translation. That is CPU first generates virtual address and before it mapped to main memory it have to go through a translation process where hardware convert virtual address to physical address via an OS managed look-up table which is called page table. Page table has provision to keeping information about main memory address as well as disk memory address. It use a valid bit to detect where the location is. In the modern PCs, workstations, servers it is used.
  • 5. PAGE 4 Figure 2: system with virtual memory Paging In computer science Paging is a Memory Management technique by which computer can store and retrieve data from secondary storage for the use of main memory. Paging is an important part of virtual memory implementation in Operating Systems, allowing them to use the disk storage for the data that does not fit into the physical RAM. The main functions of Paging are performed when a program tries to access a page that are currently not in RAM. This situation is known as page fault. The operating system must take control and handle the page fault, in a manner invisible to the program. Therefore, the OS must 1. Determine the location of the data in secondary storage. 2. Obtain an empty page frame in RAM to use as a container for the data. 3. Load the requested data into the available page frame. 4. Update page table to show new data. 5. Return control to the program.
  • 6. PAGE 5 Page Table Page table is data structure used to store mapping between virtual address to physical address. It is used to translate logical address to physical address. The entries of page table are address which contains pointer to the location of the page in memory (RAM or disk), valid bit which says that the page is in RAM or in disk, dirty bit which is set if the page is modified at least once, referenced bit which is used if page has been referenced with either read or write, this bit used to support software replacement policies. Another bit is protection bit or access right bit which is used to restrict the access, for example, read only access, write only access, system only access etc. Figure 3: page table Address Mapping Virtual address has two parts virtual page number and page offset. The number of pages addressable to the virtual address is virtually unlimited where as the number of pages addressable by the physical address is limited. CPU generates virtual address. A virtual address has two parts, virtual page number and offset. Virtual page number is index into a page table. Page table entry contains page frame number. Physical address will be then concatenation of page frame number and offset.
  • 7. PAGE 6 Figure 4: address mapping In the above image p defines virtual page number, o is offset of the page, f is the page frame number. Page translation example: assume a 32bit address space, and page size is 4KB (log2(4096) = 12bits) for a process to address the full logical address space, need 20bit virtual page number and 12 bits offset. Let we want to transform the virtual address 0x12345678. And let the offset contains 0x678. If the page table entry of 12345 contains 0x01000 then the physical address will be 0x01000678. Page Fault Page fault occurs when page is on disk rather than memory. When page fault occurs then the OS is invoked to move page from disk to main memory. At the same time current process is suspended and other can resume. And OS has full control over placement. When a process is created, the OS creates space for all the pages of a process in the disk. This disk space is called swap space. It also creates a data structure to record where each virtual page is stored in the disk. The data structure may be part of the page table or separate. The OS also creates a data structure that tracks which processes and which virtual addresses use each physical page. If all pages in main memory are in use, the OS must choose a page to replace based on the past history. The replaced pages are written to the swap space of the disk.
  • 8. PAGE 7 Figure 5: before page fault Figure 6: after page fault Page Replacement When a fault occurs, the OS loads the faulted page from disk into a page of memory. At some point, the process has used all of the page frames it is allowed to use. When this happens, the OS must replace page for each page faulted in. That is, it must select a page to throw out of primary memory to make room. There are several page replacement algorithms, like FIFO, LRU (least recent used), Least Frequently Used, optimal or minimum used etc. the goal of the page replacement is to reduce the fault rate by selecting the best victim page to remove. Example Let us use here LRU (least recently used technique). Say we have the page reference string is, 1 2 3 4 2 1 5 6 2 1 2 3 7 6 assuming there is 4 page frame available. Then the procedure will be as follows. Frame 1 1* 1* 1* 1* 1* 1 1 1 1* 1 1 1 1* 6 Frame 2 2 2 2 2 2 2 2* 2 2 2 2 2 2* Frame 3 3 3 3 3* 5 5 5 5* 5* 3 3 3 Frame 4 4 4 4 4* 6 6 6 6 6* 7 7 faults Y Y Y Y N N Y Y N N N Y Y Y
  • 9. PAGE 8 Advantage & Disadvantage  We can run more applications at once.  We can run larger applications with less real RAM.  We have large memory in disk that is larger virtual memory.  More efficient use of memory in this technique.  There is no limit or degree of multiprogramming. - Applications run slower. - It takes more time to switch between applications. - Less hard drive space for your use. References • Stallings W. (2006): “Operating Systems: Internals and Design Principles (7 th Edition)”. Prentice Hall. • Tanenbaum A. S. (2013): “Modern Operating System (3 rd edition)”, Pearson Education, pp.175-247. • Cragon, Harvey G. (1996). Memory Systems and Pipelined Processors. Jones and Bartlett Publishers. ISBN 0-86720-474-5. • Hannessy J. L, Patterson D. A. (2012). Computer Architecture a quantitative approach .Elsevier. ISBN 978-0-12-383872-8. • URL: http://windows.microsoft.com/en-us/windows/what-is-virtual- memory#1TC=windows-7 • URL: http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Memory/virtual.htm