Most Viewed Content:

OpenAI Launched Assistants API, Allowing Developers to Customize AI Assistants with One Click

At today's OpenAI's first developer conference, OpenAI launched the...

Microsoft working on new features for Win11 / Win12: smart notifications, depth-of-field effects

According to the source Albacore (@thebookisclosed), Microsoft is preparing...

India’s censorship body gave power to remove pirated Movies from platforms

India’s Ministry of Information and Broadcasting announced that its...

CPU does this without the memory

Remember me, I’m Q, the Q from CPU workshop No 1.

Today, I took some time out of my busy schedule to go to the address translation department of the factory, and Blacky, who is responsible for this work, was sweating profusely.

When he saw me coming, he pointed to the seat next to him and told me to sit down.

After sitting down for a while, Blackie turned around from his workstation, “I’m sorry, Q, there’s too much work today, I didn’t have time to entertain you.”

“What have you been up to? You’re sweaty,” I asked.

“Hey, don’t mention it, I keep finding memory page errors and keep having to notify the OS to deal with them, I miss the old days when there wasn’t so much shit to deal with”, sighed Black.

I was intrigued, “Blackie, tell me about your work, what’s the deal with address translation, and why do you miss the old days?”

Blacky adjusted his sitting position, gulped some water and said, “That’s a long story.”

Then Blacky started to tell me a history story ・・・・・・

8086
It turns out that our ancestor was called 8086, and Blackie showed me a picture of him

It was a time of innocence and simplicity, although the working performance was not high, the programs in those days were very simple, and our ancestor became a star as soon as he was introduced, which was considered the top stream of that era.

See those metal pins in the photo? Those were the tentacles of our CPU’s dealings with the outside world, and each one served a different purpose.

Through these tentacles, the CPU was able to deal with the memory, get instructions and data, and do its hard work.

In those days, conditions were poor, so we had to make do with what we could and share what we could. For example, the address bus pins and the data bus pins of the ancestor CPU were shared.

The ancestor was a 16-bit CPU, and the Data bus had 16 bits, so 16 bits could be transferred at once. This was combined with the Address bus, and the name AD0-AD15 was given to it.

But the ancestor’s address bus has more than 16, there are 4 more A16-A19! That’s 20 address lines, so you can address 1MB of memory!

But the ancestors’ registers were 16-bit, so they could only store 16-bit addresses. But they were clever enough to invent a method called segmented memory management, dividing the memory into small chunks of up to 64KB, why 64KB? Then a few things called segment registers were added to point to the beginning of these blocks so that more memory could be accessed by means of segment addresses + intra-segment offsets.

The 32-bit era
Later on, the little computing power of our ancestors became increasingly stretched and could not keep up with the times. The younger generation of the family took over and the 80286 and 80386 CPUs were introduced, especially the 80386, which became a landmark.

In the 80386 era, we had more pins to communicate with the outside world and became a 32-bit CPU, and by then, life was better, as addresses and data lines no longer had to share pins.

Later, humans became greedy and wanted to listen to music, surf the internet and edit documents at the same time, which required multiple programs to run at the same time.

At this point, someone saw a business opportunity and developed something called an operating system. It turns out that those programs no longer deal directly with our CPUs, but with the operating system, which in turn deals with us.

The operating system is very clever, it allows us to rotate our CPUs through time slices to execute multiple programs, one time we are playing music, another time we are executing a browser program, another time we are executing a document editing program. It doesn’t matter what code we are given, we don’t pick and choose, we just work hard. Humans are not nearly as fast as we are, and they think these programs are actually executing at the same time.

Virtual memory
With so many programs running, all crammed into the same memory, there is constant friction and conflict.

Our ancestors were so exhausted by this that they finally came up with a good solution, which has been used ever since.

They came up with a virtual address thing, where all programs use a virtual address, and when it comes to dealing with memory, our internal CPU staff translates it into a real memory address, about which the memory guy has been kept in the dark.

In this way, each program has access to a large range of address space from 0x00000000 to 0xffffffff, 4GB in total, but of course, they are not really given that much space, the memory guy only has 4GB in total, but have to apply for allocation on demand. The allocation of units is done on a per-page basis, with a 32-bit CPU having 4KB per page, and the OS is left to do the hard work of allocation management.

To do this, a new register, CR3, was added inside our registers to point to a dictionary of address translation queries, which is divided into two levels of directories. We divided a 32-bit address into 3 parts, the first two parts pointing to entries in the two levels of the directory to locate where in physical memory the address is located, and the last part pointing to the offset of the physical memory page, thus completing the translation of the address.

Each process has a different address space, and when switching processes, it is particularly convenient to swap the contents of CR3 to use the translation dictionary of the new process.

We call this type of memory management paged memory management.

We admire the wisdom of our ancestors for cleverly isolating individual processes in this way, and later we called this mode of working protected, and the previous mode of working directly with real memory addresses real address mode.

Paging
Humans became greedier and greedier, programs became more and more numerous and demanded more and more memory. With all these programs constantly requesting memory pages, memory space is soon to be exhausted.

We looked on in disbelief and anxiety and later approached the operating system to negotiate and see what to do about this problem.

The OS guy wasn’t too bad and came up with a good solution. The size of the memory is limited, but the hard disk is powerful, the hard disk has a lot of space, go to the hard disk to carve out an area to replace the long unused pages in the memory to this area, and then make a mark. If anyone wants to access that page later, our CPU will check for this mark and send a page error interrupt to tell the OS to switch the page back.

By working together, we were able to solve the memory crunch. We later called this technology memory paging.

Now
In our generation, memory has become much bigger, 16GB is a small case and 32GB is common.

Apart from memory, our CPUs themselves have become more advanced.

Not only have we gone from 32-bit to 64-bit, but we’ve also gone from single-core to multi-core, like the CPU I’m on, which has eight workshops and eight cores running in parallel, which is a far cry from our ancestors’ days.

Latest

2024 Beijing Auto Show: All-new Toyota Crown unveiled at the booth

At the Beijing Auto Show, which opened on April...

Teclast P50 Tablet released: Pre-installed with Android 14, Unisoc T606 processor

Teclast today officially announced the launch of its P50...

Nissan’s global sales in March were 365,845 units, YOY increase of 3.3%

Nissan announced the latest production and sales data: global...

Skyworth EV6 II super-charging car 2024 model launched: Starting from 139,800 RMB

The 2024 Skyworth EV6 II car was officially launched...

Newsletter

Don't miss

2024 Beijing Auto Show: All-new Toyota Crown unveiled at the booth

At the Beijing Auto Show, which opened on April...

Teclast P50 Tablet released: Pre-installed with Android 14, Unisoc T606 processor

Teclast today officially announced the launch of its P50...

Nissan’s global sales in March were 365,845 units, YOY increase of 3.3%

Nissan announced the latest production and sales data: global...

Skyworth EV6 II super-charging car 2024 model launched: Starting from 139,800 RMB

The 2024 Skyworth EV6 II car was officially launched...

Kia Sonet SUV launched with optional L2 smart driving assistance

Kia's entry-level SUV Sonet Motors was officially launched at...
Stephen Cruise
Stephen Cruisehttps://www.techgoing.com
Stephen Cruise is a senior editor covering latest smartphones, EVs, PC gaming, console, and tech with 11 years of experience.

Chery Li Xueyong: Fulwin uses hybrid power to roll up

"We will strive to be second in the hybrid market by the end of the year." This is the confidence expressed by Li Xueyong,...

Huawei Pura 70 Ultra satellite messaging supports sending pictures

Bruce Lee, CTO of Huawei Terminal BG, demonstrated the new satellite picture messaging function of Huawei Pura 70 Ultra satellite communication function. This function...

Smart #5 concept car manuscript released: To unveil on April 25

Smart China today released the manuscript drawing of the new Smart #5 concept car, claiming that it is "bigger, bolder, more square, and still...