Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.
-
Upload
avis-walker -
Category
Documents
-
view
224 -
download
4
Transcript of Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.
![Page 1: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/1.jpg)
Memory Management: Virtual Memory
Damian Gordon
![Page 2: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/2.jpg)
Virtual Memory
HARD DISK
(MAIN MEMORY)
(SECONDARY MEMORY)
2
CACHE 1
![Page 3: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/3.jpg)
Virtual Memory
HARD DISK
(MAIN MEMORY)
(SECONDARY MEMORY)
2
CACHE 1
![Page 4: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/4.jpg)
Virtual Memory
HARD DISK
(MAIN MEMORY)
(SECONDARY MEMORY)
2
CACHE 1Computer programs are stored
here
![Page 5: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/5.jpg)
Virtual Memory
HARD DISK
(MAIN MEMORY)
(SECONDARY MEMORY)
2
CACHE 1Computer programs are stored
hereUntil they need to
be executed
![Page 6: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/6.jpg)
Virtual Memory
HARD DISK
(MAIN MEMORY)
(SECONDARY MEMORY)
2
CACHE 1Computer programs are stored
hereUntil they need to
be executed
Then they are
moved to here
![Page 7: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/7.jpg)
In modern operating systems, before a job is loaded into main memory, it is divided into chunks, called PAGES.
Virtual Memory
![Page 8: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/8.jpg)
In modern operating systems, before a job is loaded into main memory, it is divided into chunks, called PAGES.
Virtual Memory
Job 3
![Page 9: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/9.jpg)
In modern operating systems, before a job is loaded into main memory, it is divided into chunks, called PAGES.
Virtual Memory
Job 3
Page 2Page 3Page 4Page 5Page 6
Page 1
Page 7
![Page 10: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/10.jpg)
Each PAGE is loaded into memory locations called PAGE FRAMES.
Virtual Memory
![Page 11: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/11.jpg)
Each PAGE is loaded into memory locations called PAGE FRAMES.
Virtual Memory
200Kavailable
MAINMEMORY
![Page 12: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/12.jpg)
Each PAGE is loaded into memory locations called PAGE FRAMES.
Virtual Memory
MAINMEMORY
Page Frame 1
Page Frame 2
Page Frame 3
Page Frame 4
Page Frame 5
Page Frame 6
Page Frame 7
Page Frame 8
Page Frame 9
Page Frame 10
200Kavailable
![Page 13: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/13.jpg)
If the PAGES are the exact same size as the PAGE FRAMES (and the same size as the disk sectors), this scheme works very well.
Virtual Memory
MAINMEMORY
Page Frame 1
Page Frame 2
Page Frame 3
Page Frame 4
Page Frame 5
Page Frame 6
Page Frame 7
Page Frame 8
Page Frame 9
Page Frame 10
200Kavailable
![Page 14: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/14.jpg)
The Memory Manager prepares a program for execution by doing the following:
1. Determine the number of pages in the program2. Locate enough empty page frames in main
memory3. Load all the program’s pages into them
The empty page frame does not have to be contagious.
Virtual Memory
![Page 15: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/15.jpg)
Consider a program that 350 bytes, and the page size is 100 bytes.
Virtual Memory
![Page 16: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/16.jpg)
Consider a program that 350 bytes, and the page size is 100 bytes.
Virtual Memory
Job 1:350 bytes
![Page 17: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/17.jpg)
Consider a program that 350 bytes, and the page size is 100 bytes.
Virtual Memory
Job 1:350 bytes
Page 0
![Page 18: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/18.jpg)
Consider a program that 350 bytes, and the page size is 100 bytes.
Virtual Memory
Job 1:350 bytes
Page 0
Page 1
![Page 19: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/19.jpg)
Consider a program that 350 bytes, and the page size is 100 bytes.
Virtual Memory
Job 1:350 bytes
Page 0
Page 1
Page 2
![Page 20: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/20.jpg)
Consider a program that 350 bytes, and the page size is 100 bytes.
Virtual Memory
Job 1:350 bytes
Page 0
Page 1
Page 2
Page 3
![Page 21: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/21.jpg)
Consider a program that 350 bytes, and the page size is 100 bytes.
Virtual Memory
Job 1:350 bytes
Page 0
Page 1
Page 2
Page 3
MainMemory
![Page 22: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/22.jpg)
Consider a program that 350 bytes, and the page size is 100 bytes.
Virtual Memory
Job 1:350 bytes
Page 0
Page 1
Page 2
Page 3
MainMemory
OperatingSystem
![Page 23: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/23.jpg)
Consider a program that 350 bytes, and the page size is 100 bytes.
Virtual Memory
Job 1:350 bytes
Page 0
Page 1
Page 2
Page 3
MainMemory
OperatingSystem
Page 2
Page 0
Page 1Page 3
![Page 24: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/24.jpg)
Consider a program that 350 bytes, and the page size is 100 bytes.
Virtual Memory
Job 1:350 bytes
Page 0
Page 1
Page 2
Page 3
MainMemory
OperatingSystem
Page 2
Page 0
Page 1Page 3
A little bit of internal
fragmentation
![Page 25: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/25.jpg)
A useful extension to the notion of PAGING is DEMAND PAGING.
Demand Paging introduces the notion that you don’t have to load the whole program into memory, just part of it.
Because not all of the program needs to be in memory at the same time.
Demand Paging
![Page 26: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/26.jpg)
This means that lots of programs can be run at the same time, and there is an illusion of a significantly larger amount of memory than with regular paging.
Demand Paging
![Page 27: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/27.jpg)
To make this work, pages have to be moved very quickly from Secondary Storage to Main Memory and back again (this is called “swapping”).
Demand Paging
![Page 28: Damian Gordon. HARD DISK (MAIN MEMORY) (SECONDARY MEMORY) 2 CACHE 1.](https://reader030.fdocuments.net/reader030/viewer/2022020417/56649f0b5503460f94c1e7db/html5/thumbnails/28.jpg)
This leads to the concept of VIRTUAL MEMORY
The size of main memory appears much larger than the actual size, since many programs can appear to be fully loaded into main memory at the same time, when in actual fact, only part of many programs are loaded into main memory.
Virtual Memory