Virtual Memory: 4 How Does Virtual Memory Work? - Phụ đề song ngữ

Now, let's talk about how virtual memory works, and we're going to introduce two concepts here, virtual and physical addresses and some acronyms for them.
So how does virtual memory work?
The basic idea is we have these separate memory spaces.
So virtual memory is what a program sees.
Physical memory is the physical RAM in the computer.
When you install memory in your computer or you buy a computer with memory, this is what you're paying for.
What the program sees, the virtual memory, this is what the ISA promises.
So remember in MIPS, this promises the virtual address.
So if we do a load R4,024 R0, this is going to access a virtual address 1,024.
So the MIPS ISA promises a certain virtual memory address space, but the physical memory is what you have in your machine.
So if you have two gigabytes of RAM installed,
you're going to have physical addresses from 0 to 2 to the 31 minus 1, that's 2 billion bytes of memory.
So virtual addresses or VA,
we're going to abbreviate the virtual addresses VA, this is what the program uses, and in MIPS it's a 32-bit address space.
The physical addresses or PA, is what the hardware uses, or And this is determined by how much RAM you have installed.
If you only have a little bit of RAM installed, your physical address space, or your PA, is going to be small.
If you have a lot of RAM, it's going to be big.
But now we have separate address spaces here.
So each program is going to have its own virtual address space, and we have a physical address space for our memory.
So how do we make this work?
How does a program work?
So, the program executes a load, and the load is going to specify a virtual address because that's the way programs work.
So, here's our processor, it's running the program virtual address space, and here's our load.
So, load R3, 1024 R0.
What's the physical address going to be here?
Sorry, virtual address?
Well, it's just going to be a thing.
So the processor is going to access a virtual address 1024.
That's what this instruction is going to do.
Now, the computer is going to translate this virtual address to the physical address in the memory.
So we're going to have a translation here.
This is our map from virtual address to physical address.
And it's going to tell us how to get the data over here.
So here's the data we want for R3.
This map is going to tell us how to get this.
So we go ahead and tell the translation or the map here, we want virtual address 1,024.
It looks it up in its map, it oh, virtual address 1,024 maps to physical address 2.
So it goes over here to physical address 2,
and it goes over here Now, if the data is not in memory, it goes and loads it from disk.
In this case, it is in memory, so we're going to take this data here and we're going to return it.
So we took virtual address 1024, translated it to physical address 2, and now we send this back so we get the data.
Now, we go ahead and do another instruction.
This instruction here is going to load virtual address 512.
So we go over to our translation, ask it where 512 goes, it hey, it to physical address 12.
So we get on to physical address 12 here, go ahead and get our data, and we send it back.
Now we do another instruction, this is an add instruction, it's just using registers.
So we don't need to do any translation here.
And then we go and we have another instruction, this is going to access virtual address 700.
Sorry, 786.
So we go to virtual address 786.
The map tells us it's on disk.
It's not in memory.
Okay, it's on disk.
So what do we need to do with to get it?
Well, we need to load it into memory.
So we go ahead and load this data into memory.
Once we've loaded in memory, now we go and update the translation.
Okay, so now we no longer want to translate address 786 to disk.
We want to translate address 786 to disk location and memory.
So update that to 4.
Now when we put in virtual address 786, we get out physical address 4.
We ahead and load it from data from the memory and we return the value.
So, program executes and load with a virtual address, the computer translates it into the
physical address,
if it's not in memory,
we it from disk, and then the computer reads the RAM using the physical address and returns it to the program.
That's how virtual memory works.
So a question.
What address is located here, so address r12 has the add, sorry, value and the program issues this load.
What location in RAM is going to be accessed?
Well, we need more information here.
The program is accessing virtual address 1536,
that's what this is going to do here, but we don't know what physical address that's going to be.
So here's our processor.
It's in the program's virtual address space and we do this load.
This load is going to generate virtual address 1536,
but we're going to have a map and the map's going to tell us which physical address it is.
Now, if I don't tell you what the mapping here is, you have no idea what location in RAM this address is going to access.
So we need more information to know what memory we're actually going to access when we issue this instruction.
There's another question about using too much If a program uses more data that can fit into RAM, where does the data go?
Well, it's going to go to disk.
If it doesn't fit into the memory, we're going to use virtual memory to map it to disk.
So here's a load.
So this load's going into our table and we didn't have enough space and memory in physical memory for this virtual address.
The translation table, the map here, will tell us that it's on disk and we'll know it's on the disk.
And so you can put the data on disk if it doesn't fit into memory.

Mở khóa nhiều tính năng hơn

Cài đặt tiện ích Trancy để mở khóa nhiều tính năng hơn, bao gồm phụ đề AI, định nghĩa từ AI, phân tích ngữ pháp AI, nói chuyện AI, v.v.

feature cover

Tương thích với các nền tảng video chính

Trancy không chỉ cung cấp hỗ trợ phụ đề song ngữ cho các nền tảng như YouTube, Netflix, Udemy, Disney+, TED, edX, Kehan, Coursera, mà còn cung cấp dịch từ/câu bằng AI, dịch toàn văn sâu sắc và các tính năng khác cho các trang web thông thường. Đây là một trợ lý học ngôn ngữ đa năng thực sự.

Trình duyệt trên tất cả các nền tảng

Trancy hỗ trợ tất cả các trình duyệt trên tất cả các nền tảng, bao gồm tiện ích trình duyệt iOS Safari.

Nhiều chế độ xem

Hỗ trợ chế độ xem rạp, đọc, kết hợp và các chế độ xem khác để có trải nghiệm song ngữ toàn diện.

Nhiều chế độ luyện tập

Hỗ trợ luyện viết câu, đánh giá nói, trắc nghiệm nhiều lựa chọn, viết theo mẫu và các chế độ luyện tập khác.

Tóm tắt video AI

Sử dụng OpenAI để tóm tắt video và nắm bắt nhanh nội dung chính.

Phụ đề AI

Tạo phụ đề AI chính xác và nhanh chóng trên YouTube chỉ trong 3-5 phút.

Định nghĩa từ AI

Chạm vào từ trong phụ đề để tra cứu định nghĩa, với định nghĩa dựa trên AI.

Phân tích ngữ pháp AI

Phân tích ngữ pháp câu để nhanh chóng hiểu ý nghĩa câu và nắm vững các điểm ngữ pháp khó.

Nhiều tính năng web khác

Ngoài phụ đề song ngữ cho video, Trancy còn cung cấp dịch từ và dịch toàn văn cho các trang web.

Sẵn sàng để bắt đầu

Hãy thử Trancy ngay hôm nay và trải nghiệm các tính năng độc đáo của nó cho chính bạn

Tải về