In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > IT Information >
Share
Shulou(Shulou.com)11/24 Report--
This article comes from the official account of Wechat: programming Technology Universe (ID:xuanyuancoding), author: Xuanyuan Wind
Do you still remember me? I am Ah Q from the No. 1 CPU workshop in Ah Qjin.
Today, I went to the address translation department of the factory to take a look around. Xiao Hei, who was in charge of this work, was sweating all over his head.
Seeing my arrival, Blackie pointed to the seat next to me and motioned to me to sit down.
After sitting for a long time, Xiao Hei turned around from the station and said, "I'm really sorry, Ah Q, I have too much work to do today. I didn't have time to entertain you."
"what have you been up to? you're sweating," I asked.
"Hey, forget it. I always find errors in memory pages and keep telling the operating system to deal with them. I really miss the past, when there were not so many stupid things to take care of," Xiao Hei sighed.
As soon as I heard it, I was interested. "Xiao Hei, tell me about your work, address translation, and why do you miss the past?"
Blackie adjusted his sitting position, and Gollum took a few sips of water and said, "that's a long story."
Next, Blackie began to tell me a historical story.
8086 it turned out that our ancestor's name was 8086. Blackie showed me his picture.
It was a pure and simple era, although the working performance was not high, but the procedures of that era were very simple, and our ancestors became stars as soon as they came out, which could be called the top class of that era.
See those metal pins in the picture? That is the antennae of our CPU dealing with the outside world, each of which has a different function.
Through these tentacles, CPU can deal with memory, get instructions and data, and work hard.
In those days, the conditions were relatively poor, so we could make do with what we could, and share what we could share. This is not, you see the ancestors CPU address bus pins and data bus pins are shared.
The ancestor is a 16-bit CPU, and the data (Data) bus has 16 bits, which can transmit 16 bits at a time. It makes do with the address (Address) bus, so it is named AD0-AD15.
However, the ancestors had more than 16 address buses and 4 more A16-A19. This has 20 address lines to address the memory of 1MB!
But the ancestors' registers are all 16-bit, so they can only hold 16-bit addresses. But they are smart enough to invent a method called segmented storage management, which divides memory into small chunks of the largest 64KB, why 64KB, because 16-bit addresses can only be so large at most. Then several things called segment registers are added to point to the beginning of these blocks, so that more memory can be accessed by means of segment address + intra-segment offset address.
After the 32-bit era, ah, the computing power of our ancestors became more and more stretched, and we really couldn't keep up with the times. The younger generation of the family began to take the lead, and 80286 and 80386CPU came out one after another, especially 80386, which became an epoch-making existence.
In the 80386 era, we will have more pins to communicate with the outside world and become 32-bit CPU. At that time, living conditions will be better, and address lines and data lines will no longer have to share pins.
Later, human beings became more and more greedy and wanted to listen to music, surf the Internet and edit documents at the same time, which required running multiple programs at the same time.
At this time, someone discovered the business opportunity and developed a thing called the operating system. It turns out that those programs no longer deal directly with our CPU, but deal with the operating system, and the operating system deals with us again. The middleman is talking about the difference.
Operating system this thing is very clever, through the time slice division let us CPU to take turns to execute multiple programs, now let us execute music playback, now let us execute browser programs, and then let us execute document editing programs. We don't care, ah, give what code is not code, we do not pick, just work hard. The speed of human response is far from ours, and they think that these programs are really executed at the same time.
Virtual memory is followed by a big problem, so many programs have to run, everyone is crowded in the same memory, there is often friction and conflicts.
The ancestors worked so hard on this matter that they finally came up with a good way, which has been used to this day.
They have come up with a virtual address, and all programs use a virtual address. When dealing with memory, our internal CPU staff will translate it into a real memory address. About this, the memory guy has been kept in the dark.
In this way, each program can use a large range of address space from 0x00000000 to 0xffffffff with a total of 4GB. Of course, it doesn't really give them that much space. The guy in memory is only 4GB in total, but has to apply for allocation on demand. The units allocated are page-by-page, 32-bit CPU and one page is 4KB. The hard work of allocation and management is done by the operating system, and middlemen can't just take advantage of not doing business. As for us CPU, we just need to do a good job of address translation.
For this reason, a new register CR3 is added to our register to point to an address translation query dictionary, which is divided into two levels of directories. We divide a 32-bit address into three parts. the first two parts point to the entries in the two-level directory to locate which page the address is in physical memory, and the last part is the offset to the physical memory page. in this way, the translation of the address is completed.
Each process has a different address space, when switching processes, change the contents of the CR3 and use the translation dictionary of the new process, which is particularly convenient.
We call this kind of memory management paged memory management.
I really admire the wisdom of our ancestors to isolate each program so cleverly. Later, we called this working mode the protected mode, and the previous working mode which directly used the real memory address as the real address mode.
Paging switching humans are becoming more and more greedy, there are more and more programs, and there is a growing demand for memory. As these programs keep applying for memory pages, the memory space will soon run out.
We saw it in the eyes, anxious in the heart, and then negotiated with the operating system to see what to do with this problem.
The operating system guy was not bad, too, and came up with a good idea. The size of the memory is limited, but the hard disk gives power, ah, the hard disk space is much larger, go to the hard disk to draw an area, change the pages in memory that have not been used for a long time to this area, and then make a mark. If anyone wants to visit that page later, we CPU will check if there is this flag and send a page error interrupt signal to the operating system to change the page back.
Through the cooperation between us, the crisis of memory shortage has been solved. Later, we called this technology memory paging swapping.
Now time flies, to our generation, memory has become larger, 16GB are all small case,32GB is also very common.
In addition to memory, our CPU itself is also more advanced, among other things, if you just look at the number of pins we have now, it is not the same as that of our ancestors.
We have not only changed from 32-bit to 64-bit, but also from single-core to multi-core. Like my CPU, there are eight workshops and eight cores running in parallel, which is very different from that of our ancestors.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.