0% found this document useful (0 votes)
39 views3 pages

Virtual Memory Complete Notes

Virtual Memory (VM) is a technique that creates the illusion of more RAM by using a portion of secondary memory, allowing larger programs to run despite limited RAM. It involves paging, where programs are divided into pages and loaded into RAM only when needed, with the OS managing page faults and replacements. Key concepts include locality of reference for predicting page usage and thrashing, which occurs when excessive page faults slow down the system.

Uploaded by

thefactquiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views3 pages

Virtual Memory Complete Notes

Virtual Memory (VM) is a technique that creates the illusion of more RAM by using a portion of secondary memory, allowing larger programs to run despite limited RAM. It involves paging, where programs are divided into pages and loaded into RAM only when needed, with the OS managing page faults and replacements. Key concepts include locality of reference for predicting page usage and thrashing, which occurs when excessive page faults slow down the system.

Uploaded by

thefactquiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Virtual Memory - Complete Explanation

1. Real Problem - Limited RAM

Computer mein jab koi bada program chalaate hain to kabhi-kabhi RAM kam pad jaati hai, aur pura program

ek saath load nahi ho pata.

Sawal: Agar program RAM se bada hai to chalega kaise?

2. Solution - Virtual Memory (VM)

Virtual Memory ek technique hai jo system ko zyada RAM hone ka illusion deti hai.

VM actually secondary memory (Hard disk) ka ek part hoti hai.

OS is part ko temporary RAM ki tarah use karta hai.

Program ko lagta hai jaise use poori RAM mil gayi hai, lekin asal mein data disk pe hota hai.

Note: Execution sirf RAM mein hota hai - VM sirf pages hold karta hai.

3. VM ka Size Kaun Decide Karta Hai?

VM ka size CPU architecture (32-bit/64-bit) aur Operating System milkar decide karte hain.

- 32-bit: ~4 GB virtual memory

- 64-bit: ~16 EB tak ja sakti hai (practical limit OS lagata hai)

4. Paging - Data ko Chhote Parts mein Baantna

Program ko pages mein divide kiya jaata hai.

RAM bhi frames mein divided hoti hai.

Pages RAM ke frames mein laakar hi execute kiye jaate hain.

5. Demand Paging - Jab Zarurat Ho Tab Page Lao

OS sirf usi page ko RAM mein laata hai jo us samay required ho.

Process:

1. CPU ko kisi page ki zarurat hoti hai.

2. OS check karta hai - page RAM mein hai?

3. Agar hai - execution continue.


Virtual Memory - Complete Explanation

4. Agar nahi - Page Fault aata hai.

6. Page Fault - Jab Required Page RAM mein Na Ho

Page Fault hone par:

- OS Virtual Memory se required page ko swap in karta hai.

- RAM mein khaali frame ho to directly daal deta hai.

- Agar frame full ho to Page Replacement Algorithm use karta hai (FIFO, LRU, etc.)

- Old page ko nikaal kar naya page RAM mein laata hai.

- Page Table update hoti hai.

7. Locality of Reference - OS ka Future Guess

OS guess karta hai kaunsa page future mein use hoga.

Types:

- Temporal Locality: Abhi jo use hua, wo dobara use ho sakta hai.

- Spatial Locality: Jo address access hua, uske aas-paas ka bhi access ho sakta hai.

8. Problem: Galat Guess -> Extra Page Faults

Kabhi OS galat page RAM mein laata hai, aur jo page hataaya, wo turant chahiye pad gaya.

Isse baar-baar Page Fault hote hain -> System slow ho jaata hai.

Is condition ko kehte hain: Thrashing

9. VM mein Data Process ke Baad Rehta Hai Kya?

Virtual Memory disk par hoti hai -> ye non-volatile hoti hai.

Lekin process terminate hone ke baad, OS:

- Uske pages ko free kar deta hai.

- Wo pages reuse ho sakte hain kisi naye process ke liye.

Physical disk par data kuch waqt tak reh sakta hai, par OS ke liye wo meaningless hota hai.

10. Final Summary


Virtual Memory - Complete Explanation

- Virtual Memory: Illusion of large RAM using disk space

- Execution: Sirf RAM mein hota hai

- Paging: Data is split into pages (program) and frames (RAM)

- Demand Paging: Pages are loaded only when needed

- Page Fault: Required page not in RAM -> OS brings it from VM

- Page Replacement: RAM full -> decide which page to remove

- Locality of Reference: OS guess karta hai kaunsa page useful hai

- Thrashing: Too many page faults due to wrong guesses

- Data after Process Ends: VM mein data ho sakta hai, par OS use free kar deta hai

You might also like