virtual memory
play

Virtual Memory 2 Schedule Today Chapter 6 - PowerPoint PPT Presentation

Computer Systems and Networks ECPE 170 Jeff Shafer University of the Pacific Virtual Memory 2 Schedule Today Chapter 6


  1. ì ¡ Computer ¡Systems ¡and ¡Networks ¡ ECPE ¡170 ¡– ¡Jeff ¡Shafer ¡– ¡University ¡of ¡the ¡Pacific ¡ Virtual ¡Memory ¡

  2. 2 ¡ Schedule ¡ ì Today ¡ ¡ ì Chapter ¡6 ¡– ¡Virtual ¡memory ¡ ì Wednesday ¡ ì Chapter ¡7 ¡– ¡Input ¡/ ¡Output ¡Systems ¡ ì Friday ¡(March ¡30 th ) ¡ ì Quiz ¡#5 ¡– ¡Chapter ¡6 ¡(Cache ¡& ¡Virtual ¡Memory) ¡ Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  3. 3 ¡ Recap ¡– ¡Virtual ¡Memory ¡ Virtual ¡Memory ¡is ¡a ¡BIG ¡LIE! ¡ What ¡the ¡System ¡Really ¡Does ¡ We ¡ lie ¡to ¡your ¡applicaMon ¡and ¡ ì tell ¡it ¡that ¡the ¡system ¡is ¡simple: ¡ Physical ¡memory ¡is ¡infinite! ¡ ì (or ¡at ¡least ¡huge) ¡ You ¡can ¡access ¡ all ¡of ¡physical ¡ ì memory ¡ Your ¡program ¡starts ¡at ¡ ì memory ¡address ¡zero ¡ Your ¡memory ¡address ¡is ¡ ì con.guous ¡and ¡ in-­‑order ¡ Your ¡memory ¡is ¡ only ¡RAM ¡ ì (main ¡memory) ¡ Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  4. 4 ¡ Recap ¡– ¡Why ¡use ¡Virtual ¡Memory? ¡ ì We ¡want ¡to ¡run ¡mulMple ¡programs ¡on ¡the ¡computer ¡ concurrently ¡ (mul.tasking) ¡ Each ¡program ¡needs ¡its ¡own ¡separate ¡memory ¡region, ¡so ¡ ì physical ¡resources ¡must ¡be ¡divided ¡ The ¡amount ¡of ¡memory ¡each ¡program ¡takes ¡could ¡vary ¡ ì dynamically ¡over ¡Mme ¡(and ¡the ¡user ¡could ¡run ¡a ¡different ¡ mix ¡of ¡apps ¡at ¡once) ¡ ì We ¡want ¡to ¡use ¡mulMple ¡types ¡of ¡storage ¡(main ¡ memory, ¡disk) ¡to ¡increase ¡performance ¡and ¡capacity ¡ ì We ¡don’t ¡want ¡the ¡programmer ¡to ¡worry ¡about ¡this ¡ Make ¡the ¡processor ¡architect ¡handle ¡these ¡details ¡ ì Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  5. 5 ¡ TLB ¡+ ¡Page ¡Table ¡+ ¡Main ¡Memory ¡+ ¡Cache ¡ Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  6. 6 ¡ Example ¡– ¡Access ¡Time ¡ ì Suppose ¡we ¡have ¡a ¡virtual ¡memory ¡(VM) ¡system ¡with ¡a ¡ TLB, ¡cache, ¡and ¡page ¡table. ¡ ¡Also ¡assume: ¡ A ¡TLB ¡hit ¡takes ¡10ns, ¡and ¡has ¡a ¡hit ¡raMo ¡of ¡92% ¡ ì A ¡cache ¡hit ¡takes ¡20ns ¡(hit ¡raMo ¡98%) ¡ ì A ¡physical ¡memory ¡reference ¡takes ¡45ns ¡(page ¡fault ¡rate ¡ ì 0.025%) ¡ A ¡disk ¡reference ¡takes ¡150ms ¡(including ¡loading ¡the ¡page ¡ ì table ¡and ¡TLB) ¡ ì For ¡a ¡page ¡fault, ¡the ¡page ¡is ¡loaded ¡from ¡disk ¡and ¡TLB ¡is ¡ updated, ¡and ¡memory ¡access ¡restarts ¡ ì How ¡long ¡does ¡it ¡take ¡to ¡access ¡a ¡word ¡if ¡it ¡is ¡not ¡in ¡ physical ¡memory? ¡ Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  7. 7 ¡ Example ¡– ¡Access ¡Time ¡ How ¡long ¡does ¡it ¡take ¡to ¡access ¡a ¡word ¡if ¡it ¡is ¡ Page ¡in ¡TLB ¡(10ns) ¡→ ¡no ¡ ¡ ì not ¡in ¡physical ¡memory? ¡ Page ¡in ¡physical ¡memory ¡(45ns) ¡→ ¡no ¡ ì Read ¡page ¡from ¡disk ¡into ¡memory ¡ ì (150ms) ¡→ ¡restart ¡ Assumes ¡a ¡free ¡page ¡ ì Page ¡in ¡TLB ¡(10ns) ¡→ ¡yes ¡ ì Block ¡in ¡cache ¡(20ns) ¡→ ¡no ¡ ì Load ¡block ¡from ¡physical ¡memory ¡ ì (45ns) ¡→ ¡done ¡ Total: ¡10ns ¡+ ¡45ns ¡+ ¡150ms ¡+ ¡10ns ¡ ì ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡+ ¡20ns ¡+ ¡45ns ¡= ¡ 150,000,130ns ¡ Aka ¡a ¡ long ¡Lme ¡ ì Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  8. 8 ¡ Example ¡– ¡Access ¡Time ¡ How ¡frequently ¡does ¡this ¡happen? ¡(i.e. ¡how ¡oPen ¡must ¡we ¡ ì go ¡to ¡disk?) ¡ TLB ¡(10ns, ¡92%), ¡Cache ¡(20ns, ¡98%), ¡ ¡ ì Memory ¡(45ns, ¡1-­‑0.025%), ¡Disk ¡(150ms) ¡ Process ¡ ì Page ¡in ¡TLB ¡→ ¡92% ¡ ì Page ¡not ¡in ¡TLB ¡(requires ¡access ¡to ¡page ¡table) ¡→ ¡8% ¡ ì Page ¡not ¡in ¡page ¡table ¡(i.e. ¡not ¡in ¡memory) ¡→ ¡0.025% ¡ ì Page ¡not ¡in ¡TLB ¡ and ¡not ¡in ¡page ¡table: ¡ ì ì 8% ¡* ¡0.025% ¡= ¡.08 ¡* ¡.00025 ¡= ¡0.00002 ¡(or ¡0.002%) ¡ What ¡is ¡the ¡ effec$ve ¡access ¡$me ¡for ¡a ¡page ¡fault? ¡ ì .00002 ¡* ¡150,000,130ns ¡= ¡3,000.0026ns ¡ ì Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  9. 9 ¡ ì ¡ Segmentation ¡and ¡Fragmentation ¡ Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  10. 10 ¡ Segmentation ¡ Alternate ¡way ¡to ¡implement ¡virtual ¡memory ¡instead ¡of ¡pages: ¡ ì segmentaLon ¡ Idea: ¡Instead ¡of ¡dividing ¡memory ¡into ¡ equal-­‑sized ¡pages , ¡ ì virtual ¡address ¡space ¡is ¡divided ¡into ¡ variable-­‑length ¡segments ¡ (typically ¡under ¡the ¡control ¡of ¡the ¡programmer) ¡ A ¡segment ¡is ¡located ¡through ¡its ¡entry ¡in ¡a ¡ segment ¡table ¡ ì StarMng ¡address ¡of ¡segment ¡in ¡main ¡memory ¡ ì Size ¡of ¡segment ¡ ì Page ¡fault? ¡OperaMng ¡system ¡searches ¡for ¡a ¡locaMon ¡in ¡ ì memory ¡large ¡enough ¡to ¡hold ¡the ¡segment ¡that ¡is ¡retrieved ¡ from ¡disk. ¡ Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  11. 11 ¡ Fragmentation ¡ ì Both ¡paging ¡and ¡segmentaMon ¡can ¡cause ¡ fragmentaLon ¡ ì Paging ¡is ¡subject ¡to ¡ internal ¡fragmentaLon ¡ A ¡process ¡may ¡not ¡need ¡the ¡enMre ¡range ¡of ¡addresses ¡ ì contained ¡ within ¡the ¡page ¡ There ¡may ¡be ¡many ¡pages ¡containing ¡unused ¡fragments ¡ ì of ¡memory ¡ ¡ ì SegmentaMon ¡is ¡subject ¡to ¡ external ¡fragmentaLon ¡ ConMguous ¡chunks ¡of ¡memory ¡become ¡broken ¡up ¡as ¡ ì segments ¡are ¡allocated ¡and ¡deallocated ¡over ¡Mme ¡ FragmentaMon ¡is ¡“outside” ¡the ¡segment ¡ ì Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  12. 12 ¡ Fragmentation ¡ ì Example ¡computer ¡ 32K ¡main ¡memory ¡ ì Divided ¡into ¡8 ¡page ¡frames ¡of ¡4K ¡each ¡ ì ì The ¡numbers ¡at ¡the ¡right ¡are ¡memory ¡ frame ¡addresses ¡ Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  13. 13 ¡ Internal ¡Fragmentation ¡ ì Suppose ¡there ¡are ¡four ¡ processes ¡waiMng ¡to ¡be ¡ loaded ¡into ¡the ¡system ¡with ¡ memory ¡requirements ¡as ¡ shown ¡in ¡the ¡table ¡ ì All ¡together, ¡these ¡processes ¡ require ¡31K ¡of ¡memory ¡ This ¡should ¡all ¡fit, ¡right? ¡ ì Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  14. 14 ¡ Internal ¡Fragmentation ¡ ì When ¡the ¡first ¡three ¡processes ¡are ¡ loaded, ¡memory ¡looks ¡like ¡this: ¡ ì All ¡of ¡the ¡frames ¡are ¡occupied ¡by ¡only ¡ three ¡of ¡the ¡processes ¡ Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  15. 15 ¡ Internal ¡Fragmentation ¡ ì P4 ¡has ¡to ¡wait ¡for ¡one ¡of ¡the ¡other ¡three ¡ processes ¡to ¡terminate, ¡ ¡ There ¡are ¡no ¡unallocated ¡frames ¡available ¡ ì But ¡there ¡ is ¡ enough ¡free ¡bytes ¡in ¡memory, ¡ ì we ¡just ¡can’t ¡use ¡them! ¡ ì This ¡is ¡an ¡example ¡of ¡ internal ¡ fragmentaLon ¡ Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

  16. 16 ¡ External ¡Fragmentation ¡ ì Suppose ¡that ¡instead ¡of ¡ frames, ¡our ¡32K ¡system ¡uses ¡ segmentaLon ¡ ì The ¡memory ¡segments ¡of ¡ two ¡processes ¡is ¡shown ¡in ¡ the ¡table ¡at ¡the ¡right ¡ 42K ¡of ¡total ¡segments ¡with ¡ ì these ¡processes ¡ ì The ¡segments ¡can ¡be ¡ allocated ¡anywhere ¡in ¡ memory ¡ Computer ¡Systems ¡and ¡Networks ¡ Spring ¡2012 ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend