SlideShare a Scribd company logo
Operating Systems Principles Memory Management Lecture 8: Virtual Memory 主講人:虞台文
Content ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Operating Systems Principles Memory Management Lecture 8: Virtual Memory Principles of Virtual Memory
The Virtual Memory ,[object Object],[object Object],[object Object]
Principles of Virtual Memory 00000000 00000000 FFFFFFFF FFFFFFFF 00000000 3FFFFFF 4 G 4 G Virtual Memory Virtual Memory Physical Memory 64 M . . . . . . . . .
Principles of Virtual Memory 00000000 00000000 FFFFFFFF FFFFFFFF 00000000 3FFFFFF 4 G 4 G Virtual Memory Virtual Memory Physical Memory 64 M Address Map Address Map . . . . . . . . .
Principles of Virtual Memory ,[object Object],[object Object],[object Object],00000000 00000000 FFFFFFFF FFFFFFFF 00000000 3FFFFFF 4 G 4 G Virtual Memory Virtual Memory Physical Memory 64 M Address Map Address Map . . . . . . . . .
Approaches ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],. . . . . . . . . . . .
Main Issues in VM Design ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Operating Systems Principles Memory Management Lecture 8: Virtual Memory Implementations of Virtual Memory
Implementations of VM ,[object Object],[object Object],[object Object],[object Object],[object Object]
Paged Virtual Memory Page No. 0 1 2 p P  1 0 w 2 n  1 1 2 Page size 2 n Virtual Memory Offset Virtual Address ( p ,  w )
Physical Memory Frame No. 0 1 2 f F  1 0 w 2 n  1 1 2 Frame size 2 n Physical Memory Offset Physical Address ( f ,  w ) The size of  physical memory  is usually much  smaller  than the size of  virtual memory .
Virtual & Physical Addresses The size of  physical memory  is usually much  smaller  than the size of  virtual memory . va pa Memory Size Address Page number  p Offset  w Frame number  f Offset  w | p | bits | w | bits |  f   | bits | w | bits
Address Mapping Address Map Given  ( p ,  w ) , how to determine  f   from  p ? Page No. 0 1 2 p P  1 Virtual Memory Frame No. 0 1 2 f F  1 Physical Memory ( p ,  w ) ( f ,  w )
Address Mapping Address Map Each process  (pid =  id )  has its own virtual memory. Given  ( id ,  p ,  w ) , how to determine  f   from  ( id ,  p ) ? Page No. 0 1 2 p P  1 Virtual Memory Frame No. 0 1 2 f F  1 Physical Memory ( id ,  p ,  w ) ( f ,  w )
Frame Tables frame  f    1 frame  f frame  f  +1 Physical Memory ID p f pid page Each process  (pid =  id )  has its own virtual memory. Given  ( id ,  p ,  w ) , how to determine  f   from  ( id ,  p ) ? ID p w ID p Frame Table  FT 0 1 f F  1 w
Address Translation via Frame Table address_map(id,p,w){  pa  = UNDEFINED;  for( f =0;  f <F; f++) if( FT [ f ].pid==id && FT [ f ].page==p)   pa  =  f +w;  return  pa ; } Each process  (pid =  id )  has its own virtual memory. Given  ( id ,  p ,  w ) , how to determine  f   from  ( id ,  p ) ?
Disadvantages ,[object Object],[object Object],[object Object]
Associative Memories as Translation Look-Aside Buffers ,[object Object],[object Object],[object Object]
Page Tables f Page Tables frame  f    1 frame  f frame  f  +1 PTR Page Table Register Physical Memory p w p w
Page Tables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],address_map(p, w) {  pa  = *( PTR +p)+w;  return  pa ; }
Demand Paging ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Demand Paging ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],resident( m ) True :  the  m th  page is in memory. False : the  m th  page is missing. ,[object Object],[object Object],[object Object],[object Object],[object Object]
Segmentation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Contiguous Allocation Per Segment Segment Tables Segment  x Segment  s Segment  y Physical Memory STR Segment Table Register s w s w
Contiguous Allocation Per Segment ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Contiguous Allocation Per Segment ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Paging with segmentation
Paging with segmentation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Paging of System Tables
Paging of System Tables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Drawback: 3   extra  memory references. ,[object Object],[object Object],[object Object],[object Object]
Translation Look-Aside Buffers (TLB) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Translation Look-Aside Buffers (TLB)
Translation Look-Aside Buffers (TLB) When the search of  ( s ,  p )  fails, the  complete  address  translation  is needed. Replacement  strategy:  LRU .
Translation Look-Aside Buffers (TLB) The buffer is searched  associatively  (in  parallel )
Operating Systems Principles Memory Management Lecture 8: Virtual Memory Memory Allocation in Paged Systems
Memory Allocation with Paging ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Global/Local Replacement Policies ,[object Object],[object Object],[object Object],[object Object]
Criteria for Performance Comparison ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Criteria for Performance Comparison ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Equivalent To be used in the following discussions. =1
Global Page Replacement Algorithms ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Optimal Replacement Algorithm (MIN) ,[object Object],[object Object],[object Object]
Example: Optimal Replacement Algorithm (MIN) RS  =  c a d b e b a b c d Replace page that will  not  be  referenced  for the longest time in the  future . c a d b e b a b c d Problem: Reference String  not   known  in advance. 2   page faults Time t RS Frame  0 Frame  1 Frame  2 Frame  3 IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 a b c d a b c d a b c d a b c d a b c d a b c e d b c e e d a b c e a b c e a b c e a b c e d a
Random Replacement ,[object Object],[object Object],[object Object],[object Object],[object Object]
The Principle of Locality ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
FIFO Replacement Algorithm ,[object Object],[object Object],[object Object],[object Object]
Example: FIFO Replacement Algorithm RS  =  c a d b e b a b c d c a d b e b a b c d Replace  oldest  page.            5   page faults Time t RS Frame  0 Frame  1 Frame  2 Frame  3 IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 a b c d a b c d a b c d a b c d a b c d e b c d d a b c e a e b c d e a c d e a b d e a b c d e a b b c c d
Example: Belady’s Anormaly RS  =  dcbadcedcbaecdcbae 17   page faults 14   page faults Time t RS Frame  0 Frame  1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 0 8 d c b a d c e d c b a e c d c b a e d d c b c b a d a d c e c e d c d c b a b e b c b c d c d b d b a e a Time t RS Frame  0 Frame  1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 0 8 Frame  2 d c b a d c e d c b a e c d c b a e d d c d c a c a d b b b a d c e d c e d c e d c e b c e b a e b a e c a e d a c d a c b a c b a c e a
Example: Belady’s Anormaly 14   page faults 15   page faults Time t RS Frame  0 Frame  1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 0 8 Frame  2 d c b a d c e d c b a e c d c b a e d d c d c a c a d b b b a d c e d c e d c e d c e b c e b a e b a e c a e d a c d a c b a c b a c e a d c b a d c e d c b a e c d c b a e d d c d c d c b b a d c b a d c b a e c b a e d b a e d c a e d c b a d c b a e c b a e c b a e d b a e d c b e d c b a d c b a e c Time t RS Frame  0 Frame  1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 0 8 Frame  2 Frame  3
Least Recently Used Replacement (LRU) ,[object Object],[object Object],[object Object],[object Object]
Example: Least Recently Used Replacement (LRU) RS  =  c a d b e b a b c d Replace  Least Recently Used   page. 3   page faults c a d b e b a b c d Time t RS Frame  0 Frame  1 Frame  2 Frame  3 IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 Queue end Queue head a b c d a b c d a b c d a b c d a b c d a b e d a b d c e c a b e d a b e d a b e d a b e c d e c d d c b a c d b a a c d b d a c b b d a c e b d a b e d a a b e d b a e d c b a e d c b a
LRU Implementation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],R  =  R n  1  R n  2 …  R 1  R 0
Second-Chance Algorithm ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Also called  clock  algorithm since search  cycles  through  page frames .
Example: Second-Chance Algorithm ,[object Object],[object Object],[object Object],cycle  through page frames RS  =  c a d b e b a b c d 4   page faults c a d b e b a b c d            Time t RS Frame  0 Frame  1 Frame  2 Frame  3 IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 a /1 b /1 c /1 d /1 a /1 b /1 c /1 d /1 a /1 b /1 c /1 d /1 a /1 b /1 c /1 d /1 a /1 b /1 c /1 d /1 e /1 b /0 c /0 d /0 e a e /1 b /1 c /0 d /0 e /1 b /0 a /1 d /0 a c e /1 b /1 a /1 d /0 e /1 b /1 a /1 c /1 c d d /1 b /0 a /0 c /0 d e
Third-Chance Algorithm ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Can be implemented by an additional bit.
Example: Third-Chance Algorithm RS  =  c a w  d b w  e b a w  b c d 3   page faults ,[object Object],[object Object],[object Object],[object Object],[object Object],c a w d b w e b a w b c d            Time t RS Frame  0 Frame  1 Frame  2 Frame  3 IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 a /00 * d /10 e /00 c /00 a /10 b /10 c /10 d /10 a /10 b /10 c /10 d /10 a /11 b /10 c /10 d /10 a /11 b /10 c /10 d /10 a /11 b /11 c /10 d /10 a /00 * b /00 * e /10 d /00 e c a /00 * b /10 * e /10 d /00 a /11 b /10 * e /10 d /00 a /11 b /10 * e /10 d /00 a /11 b /10 * e /10 c /10 c d d b
Local Page Replacement Algorithms ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Local Page Replacement Algorithms ,[object Object],[object Object],[object Object]
Optimal Page Replacement Algorithm (VMIN) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Optimal Page Replacement Algorithm (VMIN) RS  =  c c d b c e c e a d 5   page faults    = 3 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b d b c e e a a d d
Example: Optimal Page Replacement Algorithm (VMIN) RS  =  c c d b c e c e a d 5   page faults    = 3 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b d b c e e a a d d
Example: Optimal Page Replacement Algorithm (VMIN) ,[object Object],[object Object],RS  =  c c d b c e c e a d 5   page faults    = 3 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b d b c e e a a d d
Working Set Model ,[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Working Set Model RS  =  e d a   c c d b c e c e a d 5   page faults    = 3 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b a b e a d a e d
Example: Working Set Model RS  =  e d a   c c d b c e c e a d 5   page faults    = 3 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b a b e a d a e d
Approximate Working Set Model ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Page Fault Frequency (PFF) Replacement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Page Fault Frequency (PFF) Replacement RS  =  c c d b c e c e a d 5   page faults    = 2 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b a ,  e e a d a e b ,  d
Example: Page Fault Frequency (PFF) Replacement RS  =  c c d b c e c e a d 5   page faults    = 2 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b a ,  e e a d a e b ,  d
Load Control and Thrashing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Load control   Choosing Degree of Multiprogramming ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Load control   Choosing Degree of Multiprogramming ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],L  =  mean time between faults S  =  mean page fault service time
Load control   Choosing Degree of Multiprogramming ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],L  =  mean time between faults S  =  mean page fault service time How  to determine the optimum, i.e.,   N max Thrashing
Load control   Choosing Degree of Multiprogramming ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],How  to determine  N max  ?
Load control   Choosing the Process to Deactivate ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Load control    Prepaging  ,[object Object],[object Object]
Evaluation of Paging ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Evaluation of Paging
Evaluation of Paging A process requires a certain percentages of its pages within the  short time period after activation . Prepaging is important.
Evaluation of Paging Smaller page size is beneficial. Another  advantage  with a small page size: Reduce  memory waste due to  internal  fragmentation . However,  small   pages  require  lager page tables .
Evaluation of Paging W : Minimum amount of memory to avoid  thrashing . Load control is important.

More Related Content

What's hot

Ui disk & terminal drivers
Ui disk & terminal driversUi disk & terminal drivers
Ui disk & terminal drivers
Sarang Ananda Rao
 
The reasons why 64-bit programs require more stack memory
The reasons why 64-bit programs require more stack memoryThe reasons why 64-bit programs require more stack memory
The reasons why 64-bit programs require more stack memory
PVS-Studio
 
Large Scale Data Analysis with Map/Reduce, part I
Large Scale Data Analysis with Map/Reduce, part ILarge Scale Data Analysis with Map/Reduce, part I
Large Scale Data Analysis with Map/Reduce, part I
Marin Dimitrov
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13
ecomputernotes
 
T5 2017 database_searching_v_upload
T5 2017 database_searching_v_uploadT5 2017 database_searching_v_upload
T5 2017 database_searching_v_upload
Prof. Wim Van Criekinge
 
Inside database
Inside databaseInside database
Inside database
Takashi Hoshino
 
Chapter 04
Chapter 04Chapter 04
Chapter 04
Google
 
Computer architecture cache memory
Computer architecture cache memoryComputer architecture cache memory
Computer architecture cache memory
Mazin Alwaaly
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
myrajendra
 
Hive query optimization infinity
Hive query optimization infinityHive query optimization infinity
Hive query optimization infinity
Shashwat Shriparv
 
cache memory
cache memorycache memory
Best Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Best Practices for Migrating Legacy Data Warehouses into Amazon RedshiftBest Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Best Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Amazon Web Services
 

What's hot (12)

Ui disk & terminal drivers
Ui disk & terminal driversUi disk & terminal drivers
Ui disk & terminal drivers
 
The reasons why 64-bit programs require more stack memory
The reasons why 64-bit programs require more stack memoryThe reasons why 64-bit programs require more stack memory
The reasons why 64-bit programs require more stack memory
 
Large Scale Data Analysis with Map/Reduce, part I
Large Scale Data Analysis with Map/Reduce, part ILarge Scale Data Analysis with Map/Reduce, part I
Large Scale Data Analysis with Map/Reduce, part I
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13
 
T5 2017 database_searching_v_upload
T5 2017 database_searching_v_uploadT5 2017 database_searching_v_upload
T5 2017 database_searching_v_upload
 
Inside database
Inside databaseInside database
Inside database
 
Chapter 04
Chapter 04Chapter 04
Chapter 04
 
Computer architecture cache memory
Computer architecture cache memoryComputer architecture cache memory
Computer architecture cache memory
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
 
Hive query optimization infinity
Hive query optimization infinityHive query optimization infinity
Hive query optimization infinity
 
cache memory
cache memorycache memory
cache memory
 
Best Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Best Practices for Migrating Legacy Data Warehouses into Amazon RedshiftBest Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Best Practices for Migrating Legacy Data Warehouses into Amazon Redshift
 

Viewers also liked

DSW: The first 20 Years
DSW: The first 20 YearsDSW: The first 20 Years
DSW: The first 20 Years
Matthias Stockkamp
 
Os9 2
Os9 2Os9 2
Os9 2
issbp
 
Historia de la fotografia
Historia de la fotografiaHistoria de la fotografia
Historia de la fotografia
memb90
 
Hoja de vida - Milton mayorca
Hoja de vida - Milton mayorcaHoja de vida - Milton mayorca
Hoja de vida - Milton mayorca
memb90
 
Os4
Os4Os4
Os4
issbp
 
Os6 2
Os6 2Os6 2
Os6 2
issbp
 
Pizza Hut: It's Your Hut! Campaign
Pizza Hut: It's Your Hut! CampaignPizza Hut: It's Your Hut! Campaign
Pizza Hut: It's Your Hut! Campaign
zikakiss
 
Registro de telefono
Registro de telefonoRegistro de telefono
Registro de telefono
Jhojan Ramos Vera
 
Os6
Os6Os6
Os6
issbp
 
Milton mayorca
Milton mayorcaMilton mayorca
Milton mayorca
memb90
 
Etnografía guber rosana
Etnografía   guber rosanaEtnografía   guber rosana
Etnografía guber rosana
Climer
 
Os2
Os2Os2
Os2
issbp
 
Heidegger el concepto de tiempo
Heidegger   el concepto de tiempoHeidegger   el concepto de tiempo
Heidegger el concepto de tiempo
Climer
 
Filosofía de la ciencia leon olives y ana r. pérez 453
Filosofía de la ciencia leon olives y ana r. pérez 453Filosofía de la ciencia leon olives y ana r. pérez 453
Filosofía de la ciencia leon olives y ana r. pérez 453
Climer
 
Class5
 Class5 Class5
Class5
issbp
 
Os2 2
Os2 2Os2 2
Os2 2
issbp
 
El paradigma perdido edgar morin
El paradigma perdido edgar morinEl paradigma perdido edgar morin
El paradigma perdido edgar morin
Climer
 
Ch11 input output systems
Ch11 input output systemsCh11 input output systems
Ch11 input output systems
issbp
 
L'ergonomie d'un site web par Fred Colantonio
L'ergonomie d'un site web par Fred ColantonioL'ergonomie d'un site web par Fred Colantonio
L'ergonomie d'un site web par Fred Colantonio
J'ai besoin de com
 
"Créer une campagne Google Adwords étape par étape" par Christophe Bouchat
"Créer une campagne Google Adwords étape par étape" par Christophe Bouchat"Créer une campagne Google Adwords étape par étape" par Christophe Bouchat
"Créer une campagne Google Adwords étape par étape" par Christophe BouchatJ'ai besoin de com
 

Viewers also liked (20)

DSW: The first 20 Years
DSW: The first 20 YearsDSW: The first 20 Years
DSW: The first 20 Years
 
Os9 2
Os9 2Os9 2
Os9 2
 
Historia de la fotografia
Historia de la fotografiaHistoria de la fotografia
Historia de la fotografia
 
Hoja de vida - Milton mayorca
Hoja de vida - Milton mayorcaHoja de vida - Milton mayorca
Hoja de vida - Milton mayorca
 
Os4
Os4Os4
Os4
 
Os6 2
Os6 2Os6 2
Os6 2
 
Pizza Hut: It's Your Hut! Campaign
Pizza Hut: It's Your Hut! CampaignPizza Hut: It's Your Hut! Campaign
Pizza Hut: It's Your Hut! Campaign
 
Registro de telefono
Registro de telefonoRegistro de telefono
Registro de telefono
 
Os6
Os6Os6
Os6
 
Milton mayorca
Milton mayorcaMilton mayorca
Milton mayorca
 
Etnografía guber rosana
Etnografía   guber rosanaEtnografía   guber rosana
Etnografía guber rosana
 
Os2
Os2Os2
Os2
 
Heidegger el concepto de tiempo
Heidegger   el concepto de tiempoHeidegger   el concepto de tiempo
Heidegger el concepto de tiempo
 
Filosofía de la ciencia leon olives y ana r. pérez 453
Filosofía de la ciencia leon olives y ana r. pérez 453Filosofía de la ciencia leon olives y ana r. pérez 453
Filosofía de la ciencia leon olives y ana r. pérez 453
 
Class5
 Class5 Class5
Class5
 
Os2 2
Os2 2Os2 2
Os2 2
 
El paradigma perdido edgar morin
El paradigma perdido edgar morinEl paradigma perdido edgar morin
El paradigma perdido edgar morin
 
Ch11 input output systems
Ch11 input output systemsCh11 input output systems
Ch11 input output systems
 
L'ergonomie d'un site web par Fred Colantonio
L'ergonomie d'un site web par Fred ColantonioL'ergonomie d'un site web par Fred Colantonio
L'ergonomie d'un site web par Fred Colantonio
 
"Créer une campagne Google Adwords étape par étape" par Christophe Bouchat
"Créer une campagne Google Adwords étape par étape" par Christophe Bouchat"Créer une campagne Google Adwords étape par étape" par Christophe Bouchat
"Créer une campagne Google Adwords étape par étape" par Christophe Bouchat
 

Similar to Os8 2

15 bufferand records
15 bufferand records15 bufferand records
15 bufferand records
ashish61_scs
 
Memory Management
Memory ManagementMemory Management
Unit 5Memory management.pptx
Unit 5Memory management.pptxUnit 5Memory management.pptx
Unit 5Memory management.pptx
SourabhRaj29
 
Memory management
Memory managementMemory management
VIRTUAL MEMORY
VIRTUAL MEMORYVIRTUAL MEMORY
VIRTUAL MEMORY
Kamran Ashraf
 
Memory+management
Memory+managementMemory+management
Memory+management
Kushagra Gaur
 
basics of virtual memory
basics of virtual memorybasics of virtual memory
basics of virtual memory
Adarsh Patel
 
Memory management
Memory managementMemory management
Memory management
cpjcollege
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
Wayne Jones Jnr
 
7989-lect 10.pdf
7989-lect 10.pdf7989-lect 10.pdf
7989-lect 10.pdf
RiazAhmad521284
 
Memory management
Memory managementMemory management
Memory management
Mohammad Sadiq
 
Memory Management
Memory ManagementMemory Management
Memory Management
Ramasubbu .P
 
Memory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelMemory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux Kernel
Adrian Huang
 
Memory Managment(OS).pptx
Memory Managment(OS).pptxMemory Managment(OS).pptx
Memory Managment(OS).pptx
RohitPaul71
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
C.U
 
OS_Ch9
OS_Ch9OS_Ch9
OSCh9
OSCh9OSCh9
Virtual Memory ,Direct memory addressing and indirect memory addressing prese...
Virtual Memory ,Direct memory addressing and indirect memory addressing prese...Virtual Memory ,Direct memory addressing and indirect memory addressing prese...
Virtual Memory ,Direct memory addressing and indirect memory addressing prese...
ITM University
 
Linux Memory
Linux MemoryLinux Memory
Linux Memory
Vitaly Nahshunov
 
Unit 5
Unit 5Unit 5
Unit 5
pm_ghate
 

Similar to Os8 2 (20)

15 bufferand records
15 bufferand records15 bufferand records
15 bufferand records
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Unit 5Memory management.pptx
Unit 5Memory management.pptxUnit 5Memory management.pptx
Unit 5Memory management.pptx
 
Memory management
Memory managementMemory management
Memory management
 
VIRTUAL MEMORY
VIRTUAL MEMORYVIRTUAL MEMORY
VIRTUAL MEMORY
 
Memory+management
Memory+managementMemory+management
Memory+management
 
basics of virtual memory
basics of virtual memorybasics of virtual memory
basics of virtual memory
 
Memory management
Memory managementMemory management
Memory management
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
 
7989-lect 10.pdf
7989-lect 10.pdf7989-lect 10.pdf
7989-lect 10.pdf
 
Memory management
Memory managementMemory management
Memory management
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Memory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelMemory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux Kernel
 
Memory Managment(OS).pptx
Memory Managment(OS).pptxMemory Managment(OS).pptx
Memory Managment(OS).pptx
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
 
OS_Ch9
OS_Ch9OS_Ch9
OS_Ch9
 
OSCh9
OSCh9OSCh9
OSCh9
 
Virtual Memory ,Direct memory addressing and indirect memory addressing prese...
Virtual Memory ,Direct memory addressing and indirect memory addressing prese...Virtual Memory ,Direct memory addressing and indirect memory addressing prese...
Virtual Memory ,Direct memory addressing and indirect memory addressing prese...
 
Linux Memory
Linux MemoryLinux Memory
Linux Memory
 
Unit 5
Unit 5Unit 5
Unit 5
 

More from issbp

Os10 2
Os10 2Os10 2
Os10 2
issbp
 
Os10
Os10Os10
Os10
issbp
 
Os9
Os9Os9
Os9
issbp
 
Os7 2
Os7 2Os7 2
Os7 2
issbp
 
Os7
Os7Os7
Os7
issbp
 
Os5 2
Os5 2Os5 2
Os5 2
issbp
 
Os5
Os5Os5
Os5
issbp
 
Os4 2
Os4 2Os4 2
Os4 2
issbp
 
Os3 2
Os3 2Os3 2
Os3 2
issbp
 
Os3
Os3Os3
Os3
issbp
 
Class9
 Class9 Class9
Class9
issbp
 
Class8
 Class8 Class8
Class8
issbp
 
Class7
 Class7 Class7
Class7
issbp
 
Class6
 Class6 Class6
Class6
issbp
 
Class4
 Class4 Class4
Class4
issbp
 
Class3
 Class3 Class3
Class3
issbp
 
Class2
 Class2 Class2
Class2
issbp
 
Class1
 Class1 Class1
Class1
issbp
 
0227 regularlanguages
 0227 regularlanguages 0227 regularlanguages
0227 regularlanguages
issbp
 

More from issbp (19)

Os10 2
Os10 2Os10 2
Os10 2
 
Os10
Os10Os10
Os10
 
Os9
Os9Os9
Os9
 
Os7 2
Os7 2Os7 2
Os7 2
 
Os7
Os7Os7
Os7
 
Os5 2
Os5 2Os5 2
Os5 2
 
Os5
Os5Os5
Os5
 
Os4 2
Os4 2Os4 2
Os4 2
 
Os3 2
Os3 2Os3 2
Os3 2
 
Os3
Os3Os3
Os3
 
Class9
 Class9 Class9
Class9
 
Class8
 Class8 Class8
Class8
 
Class7
 Class7 Class7
Class7
 
Class6
 Class6 Class6
Class6
 
Class4
 Class4 Class4
Class4
 
Class3
 Class3 Class3
Class3
 
Class2
 Class2 Class2
Class2
 
Class1
 Class1 Class1
Class1
 
0227 regularlanguages
 0227 regularlanguages 0227 regularlanguages
0227 regularlanguages
 

Os8 2

  • 1. Operating Systems Principles Memory Management Lecture 8: Virtual Memory 主講人:虞台文
  • 2.
  • 3. Operating Systems Principles Memory Management Lecture 8: Virtual Memory Principles of Virtual Memory
  • 4.
  • 5. Principles of Virtual Memory 00000000 00000000 FFFFFFFF FFFFFFFF 00000000 3FFFFFF 4 G 4 G Virtual Memory Virtual Memory Physical Memory 64 M . . . . . . . . .
  • 6. Principles of Virtual Memory 00000000 00000000 FFFFFFFF FFFFFFFF 00000000 3FFFFFF 4 G 4 G Virtual Memory Virtual Memory Physical Memory 64 M Address Map Address Map . . . . . . . . .
  • 7.
  • 8.
  • 9.
  • 10. Operating Systems Principles Memory Management Lecture 8: Virtual Memory Implementations of Virtual Memory
  • 11.
  • 12. Paged Virtual Memory Page No. 0 1 2 p P  1 0 w 2 n  1 1 2 Page size 2 n Virtual Memory Offset Virtual Address ( p , w )
  • 13. Physical Memory Frame No. 0 1 2 f F  1 0 w 2 n  1 1 2 Frame size 2 n Physical Memory Offset Physical Address ( f , w ) The size of physical memory is usually much smaller than the size of virtual memory .
  • 14. Virtual & Physical Addresses The size of physical memory is usually much smaller than the size of virtual memory . va pa Memory Size Address Page number p Offset w Frame number f Offset w | p | bits | w | bits | f | bits | w | bits
  • 15. Address Mapping Address Map Given ( p , w ) , how to determine f from p ? Page No. 0 1 2 p P  1 Virtual Memory Frame No. 0 1 2 f F  1 Physical Memory ( p , w ) ( f , w )
  • 16. Address Mapping Address Map Each process (pid = id ) has its own virtual memory. Given ( id , p , w ) , how to determine f from ( id , p ) ? Page No. 0 1 2 p P  1 Virtual Memory Frame No. 0 1 2 f F  1 Physical Memory ( id , p , w ) ( f , w )
  • 17. Frame Tables frame f  1 frame f frame f +1 Physical Memory ID p f pid page Each process (pid = id ) has its own virtual memory. Given ( id , p , w ) , how to determine f from ( id , p ) ? ID p w ID p Frame Table FT 0 1 f F  1 w
  • 18. Address Translation via Frame Table address_map(id,p,w){ pa = UNDEFINED; for( f =0; f <F; f++) if( FT [ f ].pid==id && FT [ f ].page==p) pa = f +w; return pa ; } Each process (pid = id ) has its own virtual memory. Given ( id , p , w ) , how to determine f from ( id , p ) ?
  • 19.
  • 20.
  • 21. Page Tables f Page Tables frame f  1 frame f frame f +1 PTR Page Table Register Physical Memory p w p w
  • 22.
  • 23.
  • 24.
  • 25.
  • 26. Contiguous Allocation Per Segment Segment Tables Segment x Segment s Segment y Physical Memory STR Segment Table Register s w s w
  • 27.
  • 28.
  • 30.
  • 32.
  • 33.
  • 35. Translation Look-Aside Buffers (TLB) When the search of ( s , p ) fails, the complete address translation is needed. Replacement strategy: LRU .
  • 36. Translation Look-Aside Buffers (TLB) The buffer is searched associatively (in parallel )
  • 37. Operating Systems Principles Memory Management Lecture 8: Virtual Memory Memory Allocation in Paged Systems
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44. Example: Optimal Replacement Algorithm (MIN) RS = c a d b e b a b c d Replace page that will not be referenced for the longest time in the future . c a d b e b a b c d Problem: Reference String not known in advance. 2 page faults Time t RS Frame 0 Frame 1 Frame 2 Frame 3 IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 a b c d a b c d a b c d a b c d a b c d a b c e d b c e e d a b c e a b c e a b c e a b c e d a
  • 45.
  • 46.
  • 47.
  • 48. Example: FIFO Replacement Algorithm RS = c a d b e b a b c d c a d b e b a b c d Replace oldest page.            5 page faults Time t RS Frame 0 Frame 1 Frame 2 Frame 3 IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 a b c d a b c d a b c d a b c d a b c d e b c d d a b c e a e b c d e a c d e a b d e a b c d e a b b c c d
  • 49. Example: Belady’s Anormaly RS = dcbadcedcbaecdcbae 17 page faults 14 page faults Time t RS Frame 0 Frame 1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 0 8 d c b a d c e d c b a e c d c b a e d d c b c b a d a d c e c e d c d c b a b e b c b c d c d b d b a e a Time t RS Frame 0 Frame 1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 0 8 Frame 2 d c b a d c e d c b a e c d c b a e d d c d c a c a d b b b a d c e d c e d c e d c e b c e b a e b a e c a e d a c d a c b a c b a c e a
  • 50. Example: Belady’s Anormaly 14 page faults 15 page faults Time t RS Frame 0 Frame 1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 0 8 Frame 2 d c b a d c e d c b a e c d c b a e d d c d c a c a d b b b a d c e d c e d c e d c e b c e b a e b a e c a e d a c d a c b a c b a c e a d c b a d c e d c b a e c d c b a e d d c d c d c b b a d c b a d c b a e c b a e d b a e d c a e d c b a d c b a e c b a e c b a e d b a e d c b e d c b a d c b a e c Time t RS Frame 0 Frame 1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 0 8 Frame 2 Frame 3
  • 51.
  • 52. Example: Least Recently Used Replacement (LRU) RS = c a d b e b a b c d Replace Least Recently Used page. 3 page faults c a d b e b a b c d Time t RS Frame 0 Frame 1 Frame 2 Frame 3 IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 Queue end Queue head a b c d a b c d a b c d a b c d a b c d a b e d a b d c e c a b e d a b e d a b e d a b e c d e c d d c b a c d b a a c d b d a c b b d a c e b d a b e d a a b e d b a e d c b a e d c b a
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61. Example: Optimal Page Replacement Algorithm (VMIN) RS = c c d b c e c e a d 5 page faults  = 3 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b d b c e e a a d d
  • 62. Example: Optimal Page Replacement Algorithm (VMIN) RS = c c d b c e c e a d 5 page faults  = 3 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b d b c e e a a d d
  • 63.
  • 64.
  • 65. Example: Working Set Model RS = e d a c c d b c e c e a d 5 page faults  = 3 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b a b e a d a e d
  • 66. Example: Working Set Model RS = e d a c c d b c e c e a d 5 page faults  = 3 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b a b e a d a e d
  • 67.
  • 68.
  • 69. Example: Page Fault Frequency (PFF) Replacement RS = c c d b c e c e a d 5 page faults  = 2 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b a , e e a d a e b , d
  • 70. Example: Page Fault Frequency (PFF) Replacement RS = c c d b c e c e a d 5 page faults  = 2 Time t RS Page a IN t OUT t 0 1 2 3 4 5 6 7 8 9 10 c c d b c e c e a d Page b Page c Page d Page e                                                        c b a , e e a d a e b , d
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 80. Evaluation of Paging A process requires a certain percentages of its pages within the short time period after activation . Prepaging is important.
  • 81. Evaluation of Paging Smaller page size is beneficial. Another advantage with a small page size: Reduce memory waste due to internal fragmentation . However, small pages require lager page tables .
  • 82. Evaluation of Paging W : Minimum amount of memory to avoid thrashing . Load control is important.