SlideShare a Scribd company logo
1 of 16
1
Lecture 21: Virtual Memory, I/O Basics
• Today’s topics:
 Virtual memory
 I/O overview
• Reminder:
 Assignment 8 due Tue 11/21
2
Virtual Memory
• Processes deal with virtual memory – they have the
illusion that a very large address space is available to
them
• There is only a limited amount of physical memory that is
shared by all processes – a process places part of its
virtual memory in this physical memory and the rest is
stored on disk (called swap space)
• Thanks to locality, disk access is likely to be uncommon
• The hardware ensures that one process cannot access
the memory of a different process
3
Address Translation
• The virtual and physical memory are broken up into pages
Virtual address
8KB page size
page offset
virtual page
number
Translated to physical
page number
Physical address
13
4
Memory Hierarchy Properties
• A virtual memory page can be placed anywhere in physical
memory (fully-associative)
• Replacement is usually LRU (since the miss penalty is
huge, we can invest some effort to minimize misses)
• A page table (indexed by virtual page number) is used for
translating virtual to physical page number
• The page table is itself in memory
5
TLB
• Since the number of pages is very high, the page table
capacity is too large to fit on chip
• A translation lookaside buffer (TLB) caches the virtual
to physical page number translation for recent accesses
• A TLB miss requires us to access the page table, which
may not even be found in the cache – two expensive
memory look-ups to access one word of data!
• A large page size can increase the coverage of the TLB
and reduce the capacity of the page table, but also
increases memory wastage
6
TLB and Cache
• Is the cache indexed with virtual or physical address?
 To index with a physical address, we will have to first
look up the TLB, then the cache  longer access time
 Multiple virtual addresses can map to the same
physical address – must ensure that these
different virtual addresses will map to the same
location in cache – else, there will be two different
copies of the same physical memory word
• Does the tag array store virtual or physical addresses?
 Since multiple virtual addresses can map to the same
physical address, a virtual tag comparison can flag a
miss even if the correct physical memory word is present
7
Cache and TLB Pipeline
TLB
Virtual address
Tag array Data array
Physical tag comparion
Virtual page number Virtual
index
Offset
Physical page number
Physical tag
Virtually Indexed; Physically Tagged Cache
8
Bad Events
• Consider the longest latency possible for a load instruction:
 TLB miss: must look up page table to find translation for v.page P
 Calculate the virtual memory address for the page table entry
that has the translation for page P – let’s say, this is v.page Q
 TLB miss for v.page Q: will require navigation of a hierarchical
page table (let’s ignore this case for now and assume we have
succeeded in finding the physical memory location (R) for page Q)
 Access memory location R (find this either in L1, L2, or memory)
 We now have the translation for v.page P – put this into the TLB
 We now have a TLB hit and know the physical page number – this
allows us to do tag comparison and check the L1 cache for a hit
 If there’s a miss in L1, check L2 – if that misses, check in memory
 At any point, if the page table entry claims that the page is on disk,
flag a page fault – the OS then copies the page from disk to memory
and the hardware resumes what it was doing before the page fault
… phew!
9
Input/Output
CPU
Cache
Bus
Memory Disk Network USB DVD …
10
I/O Hierarchy
CPU
Cache
Memory Bus
Memory
I/O
Controller
Network USB DVD …
I/O Bus
Disk
11
Intel Example
P4
Processor
Memory
Controller
Hub
(North Bridge)
I/O
Controller
Hub
(South Bridge)
Main
Memory
Graphics output
1 Gb Ethernet
CD/DVD
Tape
Disk
System bus 800 MHz, 604 GB/sec
266 MB/sec
DDR 400
3.2 GB/sec
2.1 GB/sec
266 MB/sec
Serial ATA
150 MB/s
USB 2.0
60 MB/s
100 MB/s
100 MB/s
12
Bus Design
• The bus is a shared resource – any device can send
data on the bus (after first arbitrating for it) and all other
devices can read this data off the bus
• The address/control signals on the bus specify the
intended receiver of the message
• The length of the bus determines its speed (hence, a
hierarchy makes sense)
• Buses can be synchronous (a clock determines when each
operation must happen) or asynchronous (a handshaking
protocol is used to co-ordinate operations)
13
Memory-Mapped I/O
• Each I/O device has its own special address range
 The CPU issues commands such as these:
sw [some-data] [some-address]
 Usually, memory services these requests… if the
address is in the I/O range, memory ignores it
 The data is written into some register in the
appropriate I/O device – this serves as the command
to the device
14
Polling Vs. Interrupt-Driven
• When the I/O device is ready to respond, it can send an
interrupt to the CPU; the CPU stops what it was doing;
the OS examines the interrupt and then reads the data
produced by the I/O device (and usually stores into memory)
• In the polling approach, the CPU (OS) periodically checks
the status of the I/O device and if the device is ready with
data, the OS reads it
15
Direct Memory Access (DMA)
• Consider a disk read example: a block in disk is being
read into memory
• For each word, the CPU does a
lw [destination register] [I/O device address] and a
sw [data in above register] [memory-address]
• This would take up too much of the CPU’s time – hence,
the task is off-loaded to the DMA controller – the CPU
informs the DMA of the range of addresses to be copied
and the DMA lets the CPU know when it is done
16
Title
• Bullet

More Related Content

Similar to Memorymapping.ppt

Similar to Memorymapping.ppt (20)

L21-Introduction-to-IO.ppt
L21-Introduction-to-IO.pptL21-Introduction-to-IO.ppt
L21-Introduction-to-IO.ppt
 
Memory Managment(OS).pptx
Memory Managment(OS).pptxMemory Managment(OS).pptx
Memory Managment(OS).pptx
 
Driver development – memory management
Driver development – memory managementDriver development – memory management
Driver development – memory management
 
Os4
Os4Os4
Os4
 
Os4
Os4Os4
Os4
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
 
OSCh9
OSCh9OSCh9
OSCh9
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
 
OS_Ch9
OS_Ch9OS_Ch9
OS_Ch9
 
Viknesh
VikneshViknesh
Viknesh
 
Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2
Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2
Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2
 
Memory Management.pdf
Memory Management.pdfMemory Management.pdf
Memory Management.pdf
 
Unit-4 swapping.pptx
Unit-4 swapping.pptxUnit-4 swapping.pptx
Unit-4 swapping.pptx
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
 
ch8 Memory Management OS.pptx
ch8 Memory Management OS.pptxch8 Memory Management OS.pptx
ch8 Memory Management OS.pptx
 
CH08.pdf
CH08.pdfCH08.pdf
CH08.pdf
 
CS6401 OPERATING SYSTEMS Unit 3
CS6401 OPERATING SYSTEMS Unit 3CS6401 OPERATING SYSTEMS Unit 3
CS6401 OPERATING SYSTEMS Unit 3
 
Cs8493 unit 4
Cs8493 unit 4Cs8493 unit 4
Cs8493 unit 4
 
16. PagingImplementIssused.pptx
16. PagingImplementIssused.pptx16. PagingImplementIssused.pptx
16. PagingImplementIssused.pptx
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
 

Recently uploaded

Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改atducpo
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 

Recently uploaded (20)

Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 

Memorymapping.ppt

  • 1. 1 Lecture 21: Virtual Memory, I/O Basics • Today’s topics:  Virtual memory  I/O overview • Reminder:  Assignment 8 due Tue 11/21
  • 2. 2 Virtual Memory • Processes deal with virtual memory – they have the illusion that a very large address space is available to them • There is only a limited amount of physical memory that is shared by all processes – a process places part of its virtual memory in this physical memory and the rest is stored on disk (called swap space) • Thanks to locality, disk access is likely to be uncommon • The hardware ensures that one process cannot access the memory of a different process
  • 3. 3 Address Translation • The virtual and physical memory are broken up into pages Virtual address 8KB page size page offset virtual page number Translated to physical page number Physical address 13
  • 4. 4 Memory Hierarchy Properties • A virtual memory page can be placed anywhere in physical memory (fully-associative) • Replacement is usually LRU (since the miss penalty is huge, we can invest some effort to minimize misses) • A page table (indexed by virtual page number) is used for translating virtual to physical page number • The page table is itself in memory
  • 5. 5 TLB • Since the number of pages is very high, the page table capacity is too large to fit on chip • A translation lookaside buffer (TLB) caches the virtual to physical page number translation for recent accesses • A TLB miss requires us to access the page table, which may not even be found in the cache – two expensive memory look-ups to access one word of data! • A large page size can increase the coverage of the TLB and reduce the capacity of the page table, but also increases memory wastage
  • 6. 6 TLB and Cache • Is the cache indexed with virtual or physical address?  To index with a physical address, we will have to first look up the TLB, then the cache  longer access time  Multiple virtual addresses can map to the same physical address – must ensure that these different virtual addresses will map to the same location in cache – else, there will be two different copies of the same physical memory word • Does the tag array store virtual or physical addresses?  Since multiple virtual addresses can map to the same physical address, a virtual tag comparison can flag a miss even if the correct physical memory word is present
  • 7. 7 Cache and TLB Pipeline TLB Virtual address Tag array Data array Physical tag comparion Virtual page number Virtual index Offset Physical page number Physical tag Virtually Indexed; Physically Tagged Cache
  • 8. 8 Bad Events • Consider the longest latency possible for a load instruction:  TLB miss: must look up page table to find translation for v.page P  Calculate the virtual memory address for the page table entry that has the translation for page P – let’s say, this is v.page Q  TLB miss for v.page Q: will require navigation of a hierarchical page table (let’s ignore this case for now and assume we have succeeded in finding the physical memory location (R) for page Q)  Access memory location R (find this either in L1, L2, or memory)  We now have the translation for v.page P – put this into the TLB  We now have a TLB hit and know the physical page number – this allows us to do tag comparison and check the L1 cache for a hit  If there’s a miss in L1, check L2 – if that misses, check in memory  At any point, if the page table entry claims that the page is on disk, flag a page fault – the OS then copies the page from disk to memory and the hardware resumes what it was doing before the page fault … phew!
  • 11. 11 Intel Example P4 Processor Memory Controller Hub (North Bridge) I/O Controller Hub (South Bridge) Main Memory Graphics output 1 Gb Ethernet CD/DVD Tape Disk System bus 800 MHz, 604 GB/sec 266 MB/sec DDR 400 3.2 GB/sec 2.1 GB/sec 266 MB/sec Serial ATA 150 MB/s USB 2.0 60 MB/s 100 MB/s 100 MB/s
  • 12. 12 Bus Design • The bus is a shared resource – any device can send data on the bus (after first arbitrating for it) and all other devices can read this data off the bus • The address/control signals on the bus specify the intended receiver of the message • The length of the bus determines its speed (hence, a hierarchy makes sense) • Buses can be synchronous (a clock determines when each operation must happen) or asynchronous (a handshaking protocol is used to co-ordinate operations)
  • 13. 13 Memory-Mapped I/O • Each I/O device has its own special address range  The CPU issues commands such as these: sw [some-data] [some-address]  Usually, memory services these requests… if the address is in the I/O range, memory ignores it  The data is written into some register in the appropriate I/O device – this serves as the command to the device
  • 14. 14 Polling Vs. Interrupt-Driven • When the I/O device is ready to respond, it can send an interrupt to the CPU; the CPU stops what it was doing; the OS examines the interrupt and then reads the data produced by the I/O device (and usually stores into memory) • In the polling approach, the CPU (OS) periodically checks the status of the I/O device and if the device is ready with data, the OS reads it
  • 15. 15 Direct Memory Access (DMA) • Consider a disk read example: a block in disk is being read into memory • For each word, the CPU does a lw [destination register] [I/O device address] and a sw [data in above register] [memory-address] • This would take up too much of the CPU’s time – hence, the task is off-loaded to the DMA controller – the CPU informs the DMA of the range of addresses to be copied and the DMA lets the CPU know when it is done