Tác giả giữ toàn bộ bản quyền (All Rights Reserved) — không phải giấy phép mở. Bạn vẫn xem và học miễn phí trên OpenER; muốn tái sử dụng cần xin phép tác giả.
PROFESSOR
Hello, and welcome back to our discussion about operating system support and virtual memory.
As we are getting into understanding how does virtual memory work, it is useful to some of the physical principles of how do the memory and storage devices work.
So let's start with the memory. Memory, in this case dynamic random access memory, or DRAM for short, is built in a different process than our logic process.
It is also a CMOS type of a process, but it is optimized differently. DRAM has special DRAM bit cells.
Those are the cells optimizing the technology that store one bit of information. On the other hand, logic process is optimized for speed, interconnect, and also for logic density.
As a result, when we compare DRAM bit cell with an SRAM bit cell, we find out that the DRAM cell is much smaller.
SRAM cells are those that are being used for building microprocessor caches, and DRAM is our external main memory.
In comparison, DRAM is almost 10 times denser than the SRAM. So when we look at a modern microprocessor, we'll find in its spec sheets that it has, perhaps, tens of megabytes of cache.
On the other hand, a DRAM chip with about the same area may have more than 10 gigabytes of DRAM cells on it.
So technology for all DRAM chips is pretty much the same, or very similar, to each other.
But their protocols or interfaces that they use for talking to the microprocessors and the packaging may differ.
So in this case, we are looking at a type of DRAM that is used in desktops and servers.
It is so-called DIMM, or dual in-line memory, that has 8 or 16 DRAM chips on this small printed circuit board that plugs into a desktop or a server.
Anybody who has built a home grown workstation or a gaming rig has done that, inserted these DRAM chips into the motherboard.
On the other hand, most laptops nowadays don't really have room to fit these DRAMs.
Instead, the DRAM chips are soldered directly onto the motherboard.
In this case, we have a bit older version of a Microsoft Surface Book that has these orange chips, which are DRAM chips, soldered onto the motherboard very close to the microprocessor.
By the way, take a look at this microprocessor. This is an Intel microprocessor from a few years ago. The microprocessor was here, and it had two layers or three levels of cache on it.
And there was a last level cache that was built in the DRAM process as a separate chip next to the microprocessor on the same package.
And then when we get to cell phones, we perhaps see a third incarnation of DRAM.
In case of mobile phones like Apple iPhone, and in this case a few year old Apple A12 bionic, fits four DRAM chips on top of it.
So it uses these DDR interfaces, which is one of the protocols that is used for talking to a DRAM.
Four DRAM interfaces connect to four DRAM chips that are placed on top of the microprocessor.
So regardless of the packaging, all DRAM chips and all DRAM memory is volatile. What does that mean? That means when we turn off the power, it forgets.
So all the data that is stored in DRAM is lost. It is the same for both DRAM and SRAM. Microprocessors need power to retain data in their caches.
So do DRAM chips need supply voltage to retain the data that is stored in them. So that's why we call them volatile.
Now some of the characteristics of DRAM — latency to access the first word is roughly first word is roughly 10 nanoseconds.
And when we compare that to a processor's speed, that's 30 to 40 processor cycles. It can be more or less, depending on the class of DRAM and the speed of a microprocessor.
Then important thing to notice that each successive read or write is much faster if we are writing to a nearby place on the DRAM.
So each successive read or write happens every 0.5 to 1 nanoseconds. In every access, we bring 64 bits.
And DRAM typically support something that is called the burst mode, meaning that we can typically do these bursts of 8 or 16 reads or writes, which would essentially bring 8 or 16 times 64 bits and fill a cache line.
Now going back to just a few words about volatility, DRAM is a little bit more volatile than the SRAM. And what does that mean?
Well SRAM will retain data as long as the supply is on, but DRAM forgets. That's why it's called dynamic random access memory.
The data is stored dynamically in the form of a charge, and the charge may leak away from the DRAM cell. So it needs to be refreshed.
So every few hundreds of milliseconds, this controller that lives on the microprocessor accesses DRAM, reads the contents, and writes it back into the DRAM.
That's the process of refresh. Processor doesn't have to do anything with that. It's a function of the controller there. That's it.
That's what we need to know about the memory. Let's get in the storage. Storage is what we typically call the disk.
And there are two types of disks that we will encounter, solid state disks and hard disk drives.
They're both attached as a peripheral I/O device using some of the principles that we have outlined, but we are going to discuss more in a couple of lectures.
Both SSD and HDD are so-called non-volatile memory types, which means they retain the value even when the power is off. That's very convenient, otherwise our computers would be forgetting everything.
We would have to load the operating system and everything into the drives every time we would like to boot them.
SSD and HDD have very different characteristics and different prices.
SSD is a lot faster, so each access is something like 40 to 100 microseconds, meaning it is significantly slower than the DRAM, taking, say, 100,000 processor cycles to access the SSD.
HDD is even slower.
It takes 3 to 10 milliseconds to access a sector in a hard disk drive, which corresponds to a couple of tens of millions of microprocessor cycles.
But there is also a big difference in price.
According to today's prices, SSD is about five times more expensive than the HDD.
SSD also comes in different shapes and forms. It can be in this shape that resembles the shape of small hard disk drives, or it can be in more modern m.2 forms.
A few notes about disk drives and why are there so slow and why is data so cheap there. The disks are mostly mechanical.
They are very sophisticated electromechanical systems that store data in iron oxide, like rust. So there is a platter here that is spinning.
And there is a mechanical arm that flies over that surface and magnetizes the surface to start the data.
Conversely, when it is in a read mode, it just hovers over the surface and reads the data. Now these magnetic domains are so small. They are a few nanometers on a side.
So in order to recognize the bits, this arm flies a few nanometers above the surface. I mean, it's a really sophisticated technology. Pretty crazy stuff out there.
Data is generally organized in so-called concentric circles called tracks.
And this arm is suspended, and again, as I said, flies over. It's actually designed like a wing, and it flies over the surface of a disk.
Disks come, again, in different classes. Most of them go from 7,200 RPM to 10,000 RPM. There are some that were built with 15,000 revolutions per minute.
That's really, really fast. I mean, it's not quite a dental drill, but like a Ferrari.
So if you convert that in milliseconds, it takes about 6 milliseconds per revolution, which means that, for this kind of a disk, average random access time will be 3 milliseconds or so, maybe a little bit less.
For a typical disk drive with 7,200 RPM, that'll be about 5 milliseconds. That is why this corresponds to 10 million processor cycles.
Now when we take these apart, it's really fun to understand how they work and why they're actually so slow, because they're mechanical.
I took this video, which is very good, from Nick Parlante.
I encourage you to watch entirely where he disassembles the hard disk drive and operates it with the lid open.
Remember, they're not in vacuum because that head needs to fly over the surface, so it needs some air. If you look at it, he opens it up over here.
So you can see the spindle, the head, and he plays with it. And then when you go towards the end of the video, you can see it in action.
In this case, it is most likely copying a file from one location to another. So you can see the arm physically moving a file from one track to another.
A few other notes about that. Disk drives come in different sizes. And I know a lot about drives because I used to design read channels for disk drives.
This is a 3 and 1/2 inch disk drive, which was typical for desktops.
And when I designed the chip — actually, in these more modern drives, the board is flipped inside out so you could see who made the read channel.
And I used to go to Fry's and flip every single drive to see if they had my chip on it. This is more of a laptop drive that is 2 and 1/2 inches.
And when they got in this race, when disk drives got in the race with solid state drives with flash memory cards, they made really these 1 inch drives.
There is an actual, real moving disk inside. This was a 2 gigabyte microdrive that would go into cameras.
So speaking about flash memory and solid state drives, there is nothing mechanical in there. Solid state drives are built of something that is called the flash memory.
It's kind of similar to our DRAM, except the technology is different. It is built out of these non-volatile cells, so you somehow trap the charge inside the cell.
In DRAM, you just stored the charge in here. You trap it so that it stays inside the bit cell even if we turn off the power.
In organization, it's similar to DRAM, but it's just packed really densely, even denser than the DRAM. It is fairly fast.
It's slower than DRAM but a lot faster than the disk. But the key thing is it's organized such that we always read and write blocks. We never access bytes or words.
And it has some unusual requirements if you want to erase it. If you want to set everything to zero, you have to erase the whole block.
One thing that people kind of are mistaken, because of this trapping of the charge, the flash drives have a limited lifetime.
So you can completely erase them only a few thousand times. Nowadays, there are spare blocks and spare sectors on the drive to extend the longevity.
But solid state drives are generally less reliable than the mechanical hard disk drives.
One thing with flash drives, their flash memory, it is a miracle of technology, really, nowadays. It has become very cheap, and it really is not slowing down with scaling.
Although we can't make these individual but cells much smaller in area, what this industry has been doing is stacking them on top of each other. So you see these silos now.
There is an array of cells in each layer, and then they stack layers on top of them. I think now current production in 128 layers. But I think 256 layers are coming in now.
So that basically extends the technology scaling, so flash memory is going to continue going in the third dimension for years to come.
And that's it. We are going to get more into virtual memory after a break.
Đăng nhập để đánh giá học liệu này.
Đăng nhập để bình luận — chưa ai bình luận về học liệu này.
Không có khóa học liên quan.