What's Virtual Memory? - Computerphile

  Рет қаралды 172,639

Computerphile

Computerphile

Күн бұрын

With the news Apple are implementing Virtual Memory on the iPad, Dr Steve Bagley takes us through what virtual memory is and how it works.
Extra Bits: • EXTRA BITS: More on Pa...
/ computerphile
/ computer_phile
This video was filmed and edited by Sean Riley.
Computer Science at the University of Nottingham: bit.ly/nottscomputer
Computerphile is a sister project to Brady Haran's Numberphile. More at www.bradyharan.com

Пікірлер: 318
@JustFamilyPlaytime
@JustFamilyPlaytime Жыл бұрын
Someone take away his pastel coloured markers and give him a black pen - then we'd be able to see his diagrams!
@GrumpyDerg
@GrumpyDerg Жыл бұрын
YES!
@bentoth9555
@bentoth9555 Жыл бұрын
Orange highlighter on white paper was an awful decision.
@zaphodbeeblebrox1695
@zaphodbeeblebrox1695 Жыл бұрын
It's of course a highlighter pen, used normally to *highlight* EXISTING black text/writing.... the clue is in its title - to use as just a pen is just plain ridiculous
@franziscoschmidt
@franziscoschmidt Жыл бұрын
Hard words but justified
@bentoth9555
@bentoth9555 Жыл бұрын
@David Jameson He had, and uses later in the video, other more visible colors on hand. He could've gone with the darker ones to start.
@Richardincancale
@Richardincancale Жыл бұрын
I don’t think this was Steve’s best video. In my opinion he mixed up three important concepts that have different motivations and are easier to understand separately: relocation, virtual memory and segmentation. Early computers ran a single job at a time so the programmer could decide to start his program at any arbitrary address and place the data in memory as he wanted, there was no interference from other programs. The next step was multi programming where several programs were in memory at the same time and the processor time-sliced between them. Initially this was achieved by using a ‘relocating loader’ that adjusted any internal (relative) address references to the actual addresses in memory. Then hardware was devised to help - a Base and Limit register set that allowed each program to see its address space starting at zero and continuing up to the limit. This had the dual benefit of performing the relocation using hardware that just added the base address to each memory reference (and checking it didn’t exceed the limit) and protecting other programs (and the operating system) from getting overwritten by accidents or bugs. The Base/Limit approach continued into the 1970s (think ICL1900, IBM360) but had the disadvantage that memory needed to be allocated in one contiguous block for each program, which leads to inefficient use over time, unused gaps etc. And this at a time when memory prices were the key constraint in building large computers. To increase efficiency the team at Manchester University designed Atlas to have demand paged virtual memory, so that the need for large contiguous blocks of memory could be overcome. Finally the next generation of computers using virtual memory, eg Multics figured that you could also Segment virtual memory so as to have read only pages shared by several programs, like library routines, and other uses for shared segments were found, for inter program communications. Hope this helps.
@32768hertz
@32768hertz Жыл бұрын
this is a content channel, just something for clicks
@guywiththebottle
@guywiththebottle Жыл бұрын
I wish I understand more of the differences between the different types of memory management.
@maxpower7086
@maxpower7086 Жыл бұрын
Nice explanation dude. I'll add that to my ever expanding block of computer knowledge.
@dannystoll84
@dannystoll84 Жыл бұрын
I've been bothered by a simple question regarding virtual memory. Suppose I have some extremely time-critical program that needs to run as quickly as possible. With virtual memory, it seems to me that every time my program reads or writes to an address (presumably this happens constantly), the operating system needs to translate this address into a physical address and look there instead. Wouldn't this introduce a significant amount of runtime overhead to the program? I recognize the countless benefits of virtual memory -- from sharing memory between processes to general system security -- but are there not situations where it would be preferable to avoid this overhead and use direct physical memory access?
@Richardincancale
@Richardincancale Жыл бұрын
@@dannystoll84 Hi - doing the lookup to translate from virtual to real address is done using associative memory - one register per virtual page and this is effectively done in parallel for all pages, so it’s extremely fast - much faster than memory access. If the page is marked as not in memory then an interrupt is raised and the OS has to get the page from disk/SSD which is orders of magnitude slower. For information that is time critical or for other reasons must always be available, eg for DMA transfers, pages can be marked as being permanently resident in memory, so they are never swapped out. Hope this helps?
@I.____.....__...__
@I.____.....__...__ Жыл бұрын
Another benefit of virtual-memory is memory-isolation. It prevents programs from messing with memory of other programs, which increases stability and increases security (it's not 100%, but certainly better than letting all programs access shared physical memory).
@nullptr.
@nullptr. Жыл бұрын
Isn't that done regardless of virtualization? the OS won't let your program touch memory outside of the bounds allocated to it, being referenced directly or through translated addresses, and the shared memory for libraries will be read-only for your process regardless
@KohuGaly
@KohuGaly Жыл бұрын
@@nullptr. When your program is running your OS (likely) doesn't. The OS needs to be notified when invalid address is being accessed. For that to happen, the hardware needs to know which addresses are valid. Presumably, without asking the OS every single time a memory access happens (because that'd be colossal waste of time). It is possible to do this without virtualization, with more primitive mechanisms. But there needs to be _some_ mechanism to facilitate this.
@AndrewTSq
@AndrewTSq Жыл бұрын
I've wondered about this.. does this mean a buffer overflow is impossible then?
@TheBrainn
@TheBrainn Жыл бұрын
Back when there were operating systems like ms dos and windows 3.1 and 95 and all that jazz before program memory was virtualized the OS memory on non Unix systems would often crash whenever a program crashed, which would sometimes be every two or so hours if you were lucky
@TheBrainn
@TheBrainn Жыл бұрын
@@AndrewTSq a technical failure such as a buffer overflow or any memory leak would still just result in crashing other programs running even on virtualized OS memory, that is until software arbitration improved with the introduction of IPCs and processes/services.
@stensoft
@stensoft Жыл бұрын
6:40 There's a real benefit for multiple mappings and it's when running virtual machines: the virtualised OS does one mapping for its programs and the host OS does another to the physical RAM.
@framegrace1
@framegrace1 Жыл бұрын
Not really, each VM is just an "application". It will make no difference, the most recent used page will always be the most recent used page on all VM's anyway. Also, that would be impossible (you would need a physical MMU per each VM).
@stensoft
@stensoft Жыл бұрын
@@framegrace1 You don't need a separate MMU per VM, just a MMU which supports two levels of mapping such as Intel VT-x and AMD-V.
@dipi71
@dipi71 Жыл бұрын
@@framegrace1 If you think of running an OS just like an »application«, you might think of software-emulating the whole machine including MMU, CPU, graphics etc. Actual virtualization does much more than that, so Jan Sten Adámek's original point is an apt ovservation.
@MasterGeekMX
@MasterGeekMX Жыл бұрын
And this is the comment Steve wanted.
@davidmurphy563
@davidmurphy563 Жыл бұрын
The presenter is getting very good at asking pertinent questions. If we ever have an AI working on the meaning of life the universe and everything he could come in handy.
@lordplenty
@lordplenty Жыл бұрын
42.
@adamsbja
@adamsbja Жыл бұрын
Brady was described by Matt Parker as the audience in the room. He has a knack for asking the right questions at the right time for what the viewer is thinking.
@ShainAndrews
@ShainAndrews Жыл бұрын
@@lordplenty Thanks for all the fish.
@Danny-hj2qg
@Danny-hj2qg Жыл бұрын
I've had the question in the title of this video for numerous years. Thank you Computerphile.
@ZacharyVogt
@ZacharyVogt Жыл бұрын
The lighting + fluorescent marker was a bold choice. But I didn't dislike it as much as others seemed to have. I think it was fun and interesting, in small doses. (I certainly wouldn't want it to be the norm though.)
@HazyJ28
@HazyJ28 Жыл бұрын
Windows 10 and 11 use this technique as "fast startup", too. So, when you shut down the PC, it writes the volatile memory to the non-volatile storage. That way, your boot time is quicker. Rather than going through your entire bootloader sequence, it can just throw the written storage DATA back into RAM. Kind of like a hybrid of Hibernate mode and Sleep mode. This is why Hibernate mode is now hidden by default in Win10/Win11.
@jkobain
@jkobain Жыл бұрын
I liked that the talk mixes different concepts and approaches on RAM management - all because it has been developed on top of one another and tries to solve one common problem, in steps.
@hardlyb
@hardlyb Жыл бұрын
About 30 years ago I wrote an incremental linker for Unix (mostly for Sun, but it got ported at least a couple of times -- for all I know, it's still running someplace), and this was around the time that a lot of low-level I/O operations were starting to be written using mmap. Some colleagues suggested at the time I should forsake read() and write() and just use mmap for everything, but my experiments showed it actually made the linker slower to use that for everything, despite it being faster to use it for some things, such as incrementally updating the debugging information in the output file. I've occasionally wondered if making basic I/O depend on mmap ever happened, and if so, how they solved the performance issue I saw. But I don't program at the level anymore, so I don't know how things work these days, and I'm at the mercy of the people writing O/S stuff, instead of being one of the people inflicting my decisions on others.
@fllthdcrb
@fllthdcrb Жыл бұрын
FYI, one of the most popular home computers of the 1980s, the Commodore 64, was equipped with 64 KiB of RAM. Its CPU, the MOS 6510, divided memory into 256-byte pages. That's 8 bits of address space per page. Makes a lot of sense, considering it was an 8-bit CPU (other than addresses, of course). It even had a special "zero-page" addressing mode for some instructions, that reduced the instruction size by a byte, and often saved a cycle too, in exchange for being restricted to the lower 256 bytes. As you might imagine, that zero page was crowded with important system variables. Well, the C64 also had no virtual memory. But then, it barely had an operating system, either, so...
@toby9999
@toby9999 Жыл бұрын
I can still remember writing 6502 code all in hex for the C64. No assembler.
@ralfbaechle
@ralfbaechle Жыл бұрын
@@toby9999 Which after a while burns the hex numbers of the opcodes so badly into the brain that now about 40 years later I still do recall all the commonly used opcodes of the 6502.
@fllthdcrb
@fllthdcrb Жыл бұрын
@@toby9999 ISTR I did that a few times myself. In retrospect, it's rather hardcore. 😆 And since you said, "6502", I should mention something else. The C64 had the 6510, which was pretty much a 6502 with an added I/O port, mapped to the bottom 2 bytes of the address space (alas, sacrificing some of that precious zero page), which the C64 used for controlling bank switching (it was equipped with a full 64 KiB of RAM _and_ 20 KiB ROMs _and_ several chips with memory-mapped registers, and it wasn't possible to have all of it available at once in a single 64 KiB space) and the tape drive.
@williamdrum9899
@williamdrum9899 Жыл бұрын
@Ralf Baechle ORG 0C00 EE 20 D0 4C 00 0C
@williamdrum9899
@williamdrum9899 Жыл бұрын
@Daniel Dawson Had I known that from the beginning I would have never used $00 to store joystick reads... my game kept crashing and I had no idea why!
@TheOriginalJohnDoe
@TheOriginalJohnDoe Жыл бұрын
Starting the weekend well!
@marksterling8286
@marksterling8286 Жыл бұрын
I think it was a Sun OS implementation where we put a lot of Ram in this particular system and the OS insisted that you had to have a swap partition about 1.5x the real Ram. It meant we had to buy an extra ultra scsi disk just for a swap partition we didn’t even want. Learning experience
@b1lleman
@b1lleman Жыл бұрын
If it was Solaris then it's absolutely normal (standard) that it does non-logical things :-)
@RonJohn63
@RonJohn63 Жыл бұрын
You could have partitioned an existing HDD. The _real_ problems were that the swapping algorithms were still primitive (Linux swap partitions also needed to be 1.5x RAM size) and that Sun assumed that you wanted swap (which at the time, given RAM sizes, was reasonable).
@ralfbaechle
@ralfbaechle Жыл бұрын
Oddly I was just thinking about this a few minutes before finding your comment. That said, I thought it the minimum size of swap was twice that of physical memory? This requirement did also affect other BSD derivates and there was a technical reason for it but I long forgot it. Maybe somebody else can explain?
@ralfbaechle
@ralfbaechle Жыл бұрын
@@RonJohn63 Linux - the kernel that is - never had a requirement for swap. It's just the installers of some Linux distributions stubornly insisted on a swap partition. Sometimes one could wiggle around that, sometimes one had to just accept that and remove the swap partition after the installation was complete.
@framegrace1
@framegrace1 Жыл бұрын
That was not a caprice, or a way to sell more disk. It was recommended so the OS could store the memory and the symbols on kernel panics. So they could investigate later if needed. Almost all early Unixes did the same, Linux included. Curiously enough, nowadays Laptops use this same feature to be able to hibernate; they dump all memory to swap like when a panic, so they can restore the laptop to exactly the same state on restart.
@sharpfang
@sharpfang Жыл бұрын
There are actually microcontrollers with 4 bytes of RAM. They use flash as program and static data memory, and have 1 kilobyte of it; RAM is used only for changing data, e.g. in the hello world you'd need 1 byte of RAM to loop over the data. They are useful in smallest of embedded applications: battery monitors, pushbutton inpts, watchdog timers, simple regulators, infrared remotes and so on.
@jonasdaverio9369
@jonasdaverio9369 Жыл бұрын
I guess you would call them registers at this point, or is there any reason not to?
@sharpfang
@sharpfang Жыл бұрын
@@jonasdaverio9369 Not really. It had registers - accumulator, 12-bit pointer register, PC, status, SP (imagine using stack on that 😂). It was a specific set of chips of a family that had all the same core but with different peripherals and different RAM sizes: 4, 16, 64 and 128 bytes of RAM variants, and 1-4k program memory. This one was just the most stripped down one, cheapest of them. I got myself a 64b/1k variant with built-in ADC, never got to use it.
@jonasdaverio9369
@jonasdaverio9369 Жыл бұрын
@@sharpfang Why would you want 4 bytes of RAM if you already have so much registers? (Wow, 8 bytes of memory just with registers, that must seem a lot compared to the RAM). I can't seem to understand why it would be economical to be that restrictive on RAM when you already have a comparable amount of registers.
@sharpfang
@sharpfang Жыл бұрын
@@jonasdaverio9369 accumulator receives result of every command, so it's not suitable for storing data. 12-bit pointer register is necessary to access the program/data memory, so if you use it for storing own stuff, you can't access any static data, just your 4 bytes of RAM. Can't really mess with PC because that's what makes the program run at all. Status is essentially read-only, and changes after every command, so no storing stuff there. Only the 1 byte of SP could be usable for storing variable data.
@jonasdaverio9369
@jonasdaverio9369 Жыл бұрын
@@sharpfang Ok, my point was just that you could consider your RAM as general use registers, even though it's an external device. It would be used in a very similar way (the only difference would be adressing)
@pistonsjem
@pistonsjem Жыл бұрын
finally i can leave hundreds of tabs open on my ipad exactly like my pc
@Roxor128
@Roxor128 Жыл бұрын
I wish I only had hundreds open!
@mattthe2nd865
@mattthe2nd865 Жыл бұрын
Virtual memory makes me think of "downloading more ram".
@ohwow2074
@ohwow2074 Жыл бұрын
It kinda is like having more RAM. A process can request a block of memory from the kernel and the kernel can just give it a virtual address and still not map it to a physical location until that process really wants to write to that location. In other words the OS can lie and claim that the computer has got e.g. 16 GB of memory while it only has 8.
@Gooberpatrol66
@Gooberpatrol66 Жыл бұрын
Advertising your computer having virtual memory as a selling point in 2022 is like treating a car having wheels as a selling point.
@tanmaypanadi1414
@tanmaypanadi1414 Жыл бұрын
if it works for the normies then that's all it needs.
@Freshbott2
@Freshbott2 Жыл бұрын
That’s a bad characterisation. Not using it is reflective of a modern, resource efficient OS. I’m not aware if Android uses swap but if it does then it’s a recent addition. Notice that they didn’t add it to iOS. A mobile OS should be stingey with resources. They didn’t forget to add it. The point in bringing it to iPad is that it’s moving from a just a fork of a mobile OS to one focused around desktop style multitasking needing desktop amounts of RAM that just weren’t realistic before. If I had an older gen iPad I’d be more disappointed that it arrived at all rather than acting like Apple was late to add it.
@MattExzy
@MattExzy Жыл бұрын
@@Freshbott2 I just feel silly for assuming that iOS already used some type of swap for the past decade. But then again, I haven't purchased an iOS device in over a decade, either. I do know however that Android has had ZRAM (compressed virtual memory) since about version 4-something.
@TragicGFuel
@TragicGFuel 16 күн бұрын
@@Freshbott2 another Apple fanboy
@simplyacatenjoyinglife3260
@simplyacatenjoyinglife3260 Жыл бұрын
Who makes these thumbnails? That person needs a raise.
@Dayanto
@Dayanto Жыл бұрын
Virtual memory is also important for making 32 bit programs work seamlessly on 64 bit systems. Each program can still only target 4GB, but by translating the addresses to 64 bit, they can be spread out in physical memory and avoid overlapping memory spaces.
@williamdrum9899
@williamdrum9899 Жыл бұрын
11:07 Love how he just casually explained the concept of address mirroring. This is actually a trick the Game Boy Advance uses: A pointer to the IRQ handler is supposed to go at 0x03007FFC but an actual interrupt loads the address stored at 0x03FFFFFC which is much easier for the ARM to load due to its use of ompressed operands. Thanks to mirroring it works out to be the same value regardless.
@tracygilmore7983
@tracygilmore7983 Жыл бұрын
Guuyyyys, give the man a high contrast marker so we can see what he draws.
@InquisitiveUniverse
@InquisitiveUniverse Жыл бұрын
I actually made a video on this lol but without all the jargon. Lot's of stop gap animation as well. But listening to a master of his craft is awesome.
@c1ph3rpunk
@c1ph3rpunk Жыл бұрын
Ben Eater’s 8-bit computer, 16 bytes, hello world works.
@samuel7998
@samuel7998 Жыл бұрын
Doesn't Ben Eater's 8-bit computer means it has 8 bits for memory addressing? Meaning it can address 2^8=256 bytes? This one has 16 bytes of addressable memory, making it a 4-bit if I understand correctly.
@jope4009
@jope4009 Жыл бұрын
@@samuel7998 No. When people talk about 8-bit, 16-bit, etc. computers , they mean the width of the data bus, not the address bus.
@martinbakker7615
@martinbakker7615 Жыл бұрын
@@jope4009 actually they talk about the accumulator size. Lookup 8086 vs 8088. Same 16bit cpu except for databus.
@ysakhno
@ysakhno Жыл бұрын
"of course 16 byte CPU wouldn't be much use for anything" -- the guy obviously hasn't heard of Ben Eater
@Mythilt
@Mythilt Жыл бұрын
In a way, memory chips do this all the time, since there is the address map, the logical map, and the physical map in the chip. The address map is what the CPU see as the memory locations, e.g. 0x0023-0x0025. The logical map is how the addresses are in the chip the address sequence might be 0x0023, 0x0025, 0x0024 for instance. and the physical map is how the actual memory cells are laid out on the chip, usually bit grouped instead of byte grouped, all the first bits are grouped, then the second bits are grouped, etc. Again, the order of the bits might be different on the chip as well, with the physical locations of the third bits of the byte are next to the first bits instead of the second. I'll admit I'm a bit out of date w/regards to memory layout since its been 21 years since I worked on testing the chips, so it might not be the same anymore.
@MyzaZoo555
@MyzaZoo555 Жыл бұрын
So it's kinda like a hashtable but for hardware?
@AmitYadav-rp3ot
@AmitYadav-rp3ot 4 ай бұрын
Great video!!!
@augustovasconcellos7173
@augustovasconcellos7173 Жыл бұрын
This video would have been *really* useful to me a week ago when I was having my OS finals
@sharkie115
@sharkie115 Жыл бұрын
17:24 Linux also supports swap files. In fact you can have many swap partitions and files at the same time and even add and remove them on the fly.
@WilliamAndrea
@WilliamAndrea Жыл бұрын
You can also have virtual swap via zram!
@andreasklindt7144
@andreasklindt7144 Жыл бұрын
The good thing about swap files on linux is that you can add them on the fly if you need them and if your computer is still responsive. Swap files and partitions can also exist simultaniously for whatever reason there might be for such a setup. But I have a question about swap files, is there a way to read what data is stored in it? I mean, could a swap file be a potential security risk?
@harold2718
@harold2718 Жыл бұрын
The risk can be mitigated, but yes, see the swap-digger tool for example.
@d5uncr
@d5uncr Жыл бұрын
Yup, if your super-secret password for some reason gets swapped out anyone with read rights on the swap file/partition can potentially read it. That's why Linux whines if your swap file has public read and suggests you chmod it 0600. You can also set up cryptswap, so your file gets encrypted and you can have your swap partition on a Luks encrypted area.
@ELYESSS
@ELYESSS Жыл бұрын
If you can read the swap file, you can also read the swap partition, but also read the memory directly.
@majorgnu
@majorgnu Жыл бұрын
@@d5uncr That's why applications should keep their secrets in mlock'd memory. See: man 2 mlock
@congenio
@congenio Жыл бұрын
To answer this question, I paraphrase Seymour Cray: "Virtual memory is memory that you don't have." - what he actually said was: "Memory is like an orgasm. It's a lot better if you don't have to fake it."
@ratdude747
@ratdude747 Жыл бұрын
I thought paging files/partitions were mostly phased out due to SSD wear leveling concerns? I know this was a big issue with running windows XP/Vista on SSDs (and whether or not to have a swap partition on linux systems).
@RonJohn63
@RonJohn63 Жыл бұрын
The algorithms used by SSD controller chips got better. Of course, _the_ solution is to have lots and lots of RAM. (Thus, while my CPU is still an archaic FX-6100, the mobo is filled to it's 32GB max, and I use a SATA SSD drive.)
@framegrace1
@framegrace1 Жыл бұрын
IIRC, SSD's have a similar "Memory Mapping" technology inside which makes the wear leveling for you. So you write lineal, but the SSD scatters the data all over the place. Anyway, remember that pages on memory Pages on disk. You can use a different storage algorithm to store the page depending on the underlying storage, if you want.
@briancoverstone4042
@briancoverstone4042 Жыл бұрын
I'd like to know more about a hypervisor running multiple operating systems with identical read only blocks. Does it dedupe and combine blocks across VM guests during idle time? And does VTd speed up hypervisor memory lookups?
@christopherg2347
@christopherg2347 Жыл бұрын
1:35 You would likely need to salvage part of the initial program space, overwriting it with the output. Donald Knuts book had a challenge, writing the shortest program that fills the entire memory (including the program itself) with a single value. This would be similar, except no perfect overwriting of every memory cell is necessary.
@trelligan42
@trelligan42 Жыл бұрын
01:50 I think you just named a semiconductor company. I can see it now; *_Luminous Computers_* in some warehouse district, with a giant sign in Neon (real or simulated).
@phasm42
@phasm42 Жыл бұрын
When I first learned about virtual memory (in the context of 386 protected mode) all the pagetable stuff seemed like a bunch of convoluted nonsense. Now, I see how elegant it is, page faults transferring control to the OS to load pages of memory from disk into RAM, and the program continues on its way none the wiser.
@raindropssonroses
@raindropssonroses Жыл бұрын
I got the same sense when I initially started with this concept too. Especially multilevel paging... but the more I think about it now, all these core designs are really so beautiful and elegant. Blows my mind how the cpu literally does not know the difference between an app, a driver, our os, or anything else. All these are artificial boundaries created by us humans :) My teacher once gave the analogy of cpu being just a buzzsaw lol
@MountainKing123
@MountainKing123 Жыл бұрын
Have you ever considered a series for GPUs? I think it would be great, since there are barely any reliable and modern information about how GPUs actually work nowadays.
@electric_sand
@electric_sand 11 ай бұрын
Have you found any? I'm in the same boat, can't seem to find some solid information on GPUs
@user-yv1qs7sy9d
@user-yv1qs7sy9d Жыл бұрын
I don't know if I got correctly what the professor said about the multilevel translation but modern systems do use it. Each process commonly uses only a little of the available memory and its "pages" are adjacent which means that its translation table is mostly empty. This would waste memory to store the empty cells of the table. To counteract this, translation can be made multilevel, so that each table points to another, which exists only if the memory it points to is actually used.
@framegrace1
@framegrace1 Жыл бұрын
That is done by the kernel. (and much more). MMU Optimization is maybe the main source of speed differences between OS's. THe only thing that needs to be done fast is the memory translation. How do you configure that MMU doesn't require realtime accuracy.
@user-yv1qs7sy9d
@user-yv1qs7sy9d Жыл бұрын
@@framegrace1 Still, that doesn't change the fact that multilevel translation does happen.
@McDuffington
@McDuffington Жыл бұрын
This seems close to how cartridge game console like the NES and SNES worked. The cartridge basically is part of the memory and can be addressed immediately. So nothing needed to be loaded into memory; the game cartridge is the memory.
@cidercreekranch
@cidercreekranch Жыл бұрын
Segmented addressing. Never mention that again! :)
@nHans
@nHans Жыл бұрын
Goodness! Using two 16-bit registers on the 8086 to create a 20-bit address of the form Segment:Offset ... nightmares! Even today, when buying clothes, I get a shiver when I see _Small, Medium, Compact, Large,_ and _Huge._ 👻
@DanielJStahl
@DanielJStahl Жыл бұрын
Orange highlighter might not have been the best choice
@andljoy
@andljoy Жыл бұрын
I am more shocked iOS did not support swap/virtual memory/page before now.
@funposting8912
@funposting8912 Жыл бұрын
Internal builds have had it available for a long time, it’s not that it wasn’t possible, it’s that generally, it’s just not a good idea. As a rule, you should not need to swap on a mobile platform. Still, systems built for two applications are going to start supporting eight concurrent applications overnight, so fair enough
@Arikayx13
@Arikayx13 Жыл бұрын
RIght! What is this Apple System 7.5?
@Acorn_Anomaly
@Acorn_Anomaly Жыл бұрын
I think they did, but at an OS/program level, not app level. Same as Android.
@sub-harmonik
@sub-harmonik Жыл бұрын
.. did you watch the whole video?
@yaiirable
@yaiirable Жыл бұрын
Can I finally download more RAM?
@hedgehog125
@hedgehog125 Жыл бұрын
Is there also wear levelling for RAM? And does that use a second virtual memory lookup?
@Acorn_Anomaly
@Acorn_Anomaly Жыл бұрын
That would likely be something implemented by the memory chips/modules themselves. While that would add another level of lookup/translation, it's probably not something the CPU would be made aware of.
@CookiePepper
@CookiePepper Жыл бұрын
No wear leveling for RAM.
@StephenHoldaway
@StephenHoldaway Жыл бұрын
Wear-leveling isn't needed for DRAM, but yes it might work like that if it was required. DRAM doesn't have write endurance limitations as it's only holding a charge temporarily for each bit, unlike flash memory which needs to force a charge through a barrier to store it when unpowered, which causes a small amount of damage each time
@charlieangkor8649
@charlieangkor8649 Жыл бұрын
There is no wear levelling for RAM.
@romanboman3847
@romanboman3847 Жыл бұрын
what if there was some important data like passwords, keys can u force it to allocate on disk and then pull the plug and search on disk for this important data?
@astrix_mvp
@astrix_mvp Жыл бұрын
The implementation on iPad must be something more than a decades old computer technology? I can't get my head around this.
@kikodekliko1209
@kikodekliko1209 Жыл бұрын
How many layers of abstraction are possible before nobody in the world actually understands how a computer or application works?
@JATmatic
@JATmatic Жыл бұрын
If you ever have run a program with AddressSanitizer enabled, then you get funny amounts of virtual memory used in htop. But physical memory usage is still normal.
@j7ndominica051
@j7ndominica051 Жыл бұрын
They've boosted the saturation of orange to make the pen look radioactive, but the paper is still unreadable with insufficient contrast in brightness. Isn't this what was used to be called a memory mapped file? Programs dealing media streams wouldn't attempt to load the whole file into memory, unless the program is a dumb as Windows Sound Recorder. They'd read it from disk and use a structure like Photoshop's scratch disk for edits.
@klaxoncow
@klaxoncow Жыл бұрын
Memory-mapped files are an application of virtual memory. Like, on Linux, you use the "mmap" function to map a file into memory (it takes a file descriptor and an offset into the file as arguments). But, if you want to just allocate RAM, then you call the same function but ask for "anonymous memory" and don't supply a file descriptor. The two things are handled through the exact same system call. On Windows, the equivalent system call is called "VirtualAlloc" and it functions more or less the same way. Memory mapped files and virtual memory are the same thing, at this level, using the same system call. The difference being whether the pages you're allocating are backed up by a physical file or not (and, as mentioned, they're called "anonymous" when they're not). It's the same thing, really. "Virtual memory" is the overall mechanism, "memory mapped files" is a particular application of it to map a file into RAM pages.
@nonsuch
@nonsuch Жыл бұрын
That's a pretty trippy marker! I want one! 😛😉
@mausmalone
@mausmalone Жыл бұрын
Every once in a while Apple or Google announces a feature in one of their devices and my only reaction is "HOW did you NOT already have that?!"
@itscarl0zyall1
@itscarl0zyall1 Жыл бұрын
Why is this being drawn out on this kind of paper and highlighter? Was there no pen available? This is so hard to read
@webjoeking
@webjoeking Жыл бұрын
Virtual Pen needed to be swapped out for a real pen.
@landsgevaer
@landsgevaer Жыл бұрын
Chain paper: "what did I do wrong?"
@crcrewso
@crcrewso Жыл бұрын
Isn't dual abstraction of address space a big thing in security. I could have sworn the second layer was undersubscribed with blocks acting basically as honey pots. When the first layer tried to manually request the location in a rude way, think off by 1 C index requests, a security exception would be raised and the OS would know that there was a bad actor thread running. Please see buffer overflow vulnerability mitigation.
@ShinyQuagsire
@ShinyQuagsire Жыл бұрын
Yeah it's common to put holes in virtual memory at the start+end of the stack/heap allocations. A strcpy to a heap address then couldn't corrupt other allocations, recursion won't clobber other thread stacks, etc. It doesn't help much for array index OOBs though.
@framegrace1
@framegrace1 Жыл бұрын
AFAIK, this all comes from how kernels handle the MMU, not MMU itself or having multiple MMU's.
@jeffburrell7648
@jeffburrell7648 Жыл бұрын
Wowzer!! Apple is advancing into the 1990s! Truly magical.
@johnsenchak1428
@johnsenchak1428 Жыл бұрын
Can you do a video on Microsoft patches and how they protect the computers from vulnerabilities
@Faladrin
@Faladrin Жыл бұрын
A patch is just an update to code on the system. What the specific patch does to make things better (performance, security, new features, etc) will be different for each patch. I'm not sure what angle a video on Windows Update technology could have that would be useful for a general purpose audience.
@johnsenchak1428
@johnsenchak1428 Жыл бұрын
@@Faladrin More specially what it means by remote code execution, elevation of privileged , security bypass
@patheally
@patheally Жыл бұрын
Is this available on the M1 chip?
@bolagadalla
@bolagadalla Жыл бұрын
Would this somehow protect against attacks in memory tho? Meaning if someone is attacking the memory to try and get some data from there, and there is a virtual memory in place, would that somehow slow them down or prevent them from getting data out? Since they would be seeing one address but in fact its in another address. Or would it not matter?
@trelligan42
@trelligan42 Жыл бұрын
It makes no real difference. The computer has to know how to access the information, the manufacturer has to publish details of how it's done, the attacker will have the know-how-or it's not a successful attacker. Bad attackers get no money.😁
@bolagadalla
@bolagadalla Жыл бұрын
@@trelligan42 thank you for the clarification. I Appreciate it.
@misterhat5823
@misterhat5823 Жыл бұрын
I've done plenty of things in assembly in embedded applications using 16 bytes or less. So it certainly isn't useless.
@soraaoixxthebluesky
@soraaoixxthebluesky 11 ай бұрын
Now I know why old computers gain so much performance from SSD upgrade due to the bit of memory being copied in a storage as a form of a translated pages (swap/ swap compressed). Accessing the HDD going to be insanely slow if you're RAM limited thus replacing it with SSD going to make a significant improvement on getting the CPU fully loaded with process. Especially on 32-bit machine with 4GB of memory. Of course we are still limited by the maximum bus speed at the end of the day even with, say, SATA3 ssd.
@wisemandenny8
@wisemandenny8 Жыл бұрын
Steve has the coolest shirt on
@dericn
@dericn Жыл бұрын
and it has very strong buttons!
@vootkidss2704
@vootkidss2704 Жыл бұрын
I think that safety is important and one should use double-protection technologies, such as Oreol Staking!
@bryannguyen1260
@bryannguyen1260 Жыл бұрын
Virtual memory is backup RAM for when you play modern videogames like Warzone on an 8GB PC at the cost of fps.
@H4x4t3hN00bz
@H4x4t3hN00bz Жыл бұрын
How much delay does virtual memory introduce versus accessing memory directly?
@compuholic82
@compuholic82 Жыл бұрын
Depends on whether the requested data is located in RAM and whether the memory page has been accessed recently. The translation is built into the memory management unit (MMU). On all modern CPUs the MMU is directly integrated into the CPU which performs the translation on the fly. So for that part of the translation process: No delays. But of course there is a catch. In order for the MMU to do the translation, it needs access to the page table which is stored in memory. And memory accesses are slow compared to the CPU. So the MMU has a special cache, called the translation lookaside buffer (TLB). So for most requests, it can avoid to access the page table. And of course if the data is not stored in RAM but swapped out, it takes forever (well, compared to the speed the CPU runs) to swap the data back in. So long story short: Most of the time: No delay. A slight delay if the MMU needs to access the page table. And a huge delay of the page has been swapped out.
@primordial_platypus
@primordial_platypus Жыл бұрын
Didn’t IBM do an early version of this in the 1960’s.
@quintrankid8045
@quintrankid8045 Жыл бұрын
Yes and some earlier systems had virtual memory as well.
@ConnorKennedy16
@ConnorKennedy16 Жыл бұрын
This video screams "computerphile: late night". I love it, but it looks like you pulled Stave from a party after a few drinks and decided to make the video right then
@MacHooolahan
@MacHooolahan Жыл бұрын
A perfectly excellent description of paging - which has been around for zonks. Sorry is there something "new", couldn't see that bit :S
@ChrisLee-yr7tz
@ChrisLee-yr7tz Жыл бұрын
They didn't say paging was new.
@MacHooolahan
@MacHooolahan Жыл бұрын
@@ChrisLee-yr7tz Indeed they didn't.
@TheInternetHelpdeskPlays
@TheInternetHelpdeskPlays Жыл бұрын
Ahhh, I love how they pretend this is a new thing. I remember using windows 3 and setting up my virtual memory to be a set size rather than dynamic. Such fun.
@wearwolf2500
@wearwolf2500 Жыл бұрын
The new IPad Pro, now running on an i286.
@bilboswaggings
@bilboswaggings Жыл бұрын
Yeah, even phones have it now
@andljoy
@andljoy Жыл бұрын
How did it not have swap in the first place , at the end of the day its just a modified BSD .
@ChrisLee-yr7tz
@ChrisLee-yr7tz Жыл бұрын
Where do they pretend this is a new thing?
@MsNerthul
@MsNerthul Жыл бұрын
@@wearwolf2500 segmented memory.. Yeah!! ;)
@LanceMcCarthy
@LanceMcCarthy Жыл бұрын
You could probably do Hello World with 16 bytes because there are only 7 different characters. The rest of the bytes would be for mapping the duplicates
@majorgnu
@majorgnu Жыл бұрын
You could do Hello World with 1 byte or even less. You just need an ISA with a dedicated Hello World instruction :P
@Amonimus
@Amonimus Жыл бұрын
Wouldn't a similar thing happen when you attach a second RAM, so its starter address has to be appended to machine's total available?
@framegrace1
@framegrace1 Жыл бұрын
This is a benefit the video doesn't explain: Virtual memory allows the applications to use all the addressing space, no matter the physical amount of ram available. So in a 64 bits machine, the application can use any of the 16 billion gigabytes of addresses if it wants. The Memory Mapping unit will match it to somewhere on the memory you have. That means that appart of being 32 or 64 bits, the application doesn't care of the amount of memory. (The OS will send an error if there's not more RAM and the app will stop)
@ericsimaginaryfriend
@ericsimaginaryfriend Жыл бұрын
Nice
@chikinnunget5231
@chikinnunget5231 Жыл бұрын
Yep
@SergeMatveenko
@SergeMatveenko Жыл бұрын
Oh my! That pen...
@AboveEmAllProduction
@AboveEmAllProduction Жыл бұрын
Highlighter not the best pen 😀
@bradyblough
@bradyblough Жыл бұрын
Drawing in orange highlighter was a bad move. You’d think they’d realize that the camera wasn’t going to pick it up well.
@tyrport
@tyrport Жыл бұрын
4K is the largest amount you can do 16 bit CRC with.
@xion1305
@xion1305 Жыл бұрын
VERY 🤔 about Samsung's "RAM Plus" feature. Feel like their offering less RAM then normal then replacing it with this potential hoodwink. My thought is wether it's innovative or a just a gimmicky thing.
@dicknig1054
@dicknig1054 Жыл бұрын
Downloading Ram but legit
@jeffjiang5272
@jeffjiang5272 Жыл бұрын
I can finally download more RAM
@rynoopperman5010
@rynoopperman5010 Жыл бұрын
VMware virtualisation / MS hypervisor Mapping changes all the time cause DRS moves workloads around and re-registeres virtual memory continuously
@abeachristine5446
@abeachristine5446 Жыл бұрын
Do this damage ssd
@brandonlink6568
@brandonlink6568 Жыл бұрын
The opposite of this is a RAM drive but with 12 terabyte hard drives being economical they don't get much use anymore
@williamfarris796
@williamfarris796 Жыл бұрын
I just download more RAM when I run out
@joikaboela8849
@joikaboela8849 Жыл бұрын
wow cool vid
@alexrossouw7702
@alexrossouw7702 Жыл бұрын
Highlighters are supposed to be the most visible pen
@decanmusic2997
@decanmusic2997 Жыл бұрын
do a video about the google AI being self-aware, please!
@Computerphile
@Computerphile Жыл бұрын
coming right up :) -Sean
@decanmusic2997
@decanmusic2997 Жыл бұрын
@@Computerphile 🤩
@subliminalvibes
@subliminalvibes Жыл бұрын
Reminds me of the old 'Download extra RAM' popups. 😆
@Roxor128
@Roxor128 Жыл бұрын
Those would have been advertising memory-compression software if legitimate. You heard about it a lot back in the 1990s, but it was also quite unreliable. Get an error in the underlying compressed block of memory, and you'd be looking at the Blue Screen Of Death. Since then it's been implemented as part of the OS with improved reliability (presumably through use of error-correction codes to guard against memory errors). Windows, Linux and MacOS all support it, and one of the Linux implementations found its way into Android 4.4. The _illegitimate_ examples would range from at best just increasing the size of your swap file (something you can do yourself in about a minute and a reboot if you know where to look in Windows' copious amount of settings), often doing nothing at all, and at worst being outright malware.
@antoniopetito
@antoniopetito Жыл бұрын
I like living on the edge and disable paging.
@davidhutchinson88
@davidhutchinson88 Жыл бұрын
Couldn't follow along with the yellow marker on white paper, very hard to read
@tristanrogers1780
@tristanrogers1780 Жыл бұрын
Virtual memory is the best
@johnnyblue4799
@johnnyblue4799 Жыл бұрын
I haven't seen perforated printer paper in ages...
@lammatt
@lammatt Жыл бұрын
Download more ram?
@aw34565
@aw34565 Жыл бұрын
10PRINT"HELLO WORLD" on my BBC Micro takes 20 bytes (The difference between TOP and PAGE).
@pilotandy_com
@pilotandy_com Жыл бұрын
Isn’t that essentially what mmap in c is doing?
@sweepingtime
@sweepingtime Жыл бұрын
Instead of marker on brown paper today it's highlighter on printer paper my eyes, ahhh!
@delmonti
@delmonti Жыл бұрын
..."if you're old enough to remember hard disks"..... Oh my!
@toby9999
@toby9999 Жыл бұрын
I can remember floppys. The thin flat ones that were actually floppy. The first computer I used only had storage on cassette tapes with a massive transfer rate of 300 bits per sec.
@landsgevaer
@landsgevaer Жыл бұрын
@@toby9999 I used to record computer programs that were broadcast on the radio once a week onto cassette, I remember. WiFi avant la lettre. Don't remember it working very often though.
@Lion_McLionhead
@Lion_McLionhead Жыл бұрын
The lion kingdom has always turned off swap space for solid state storage, out of fear of using up the write cycles. Not sure if they're doing it for planned obsolescence or because people have enough money to just not care about write cycles.
@sushanshakya
@sushanshakya Жыл бұрын
It's very confusing that the OS will somehow manage the logic of Virtual memory as OS is also running in the CPU and possibly using the data from RAM itself.
@briancoverstone4042
@briancoverstone4042 Жыл бұрын
Some RAM is marked as Do Not Swap. Such as the code that does the actual memory swapping. Otherwise it could swap itself out, similar to one eating their own head.
@MePeterNicholls
@MePeterNicholls Жыл бұрын
Hello world in ascii might work but ut8 🤷🏽‍♂️
@SirHackaL0t.
@SirHackaL0t. Жыл бұрын
Fyi, orange highlighter is not the best choice for showing info on paper.
@charlieangkor8649
@charlieangkor8649 Жыл бұрын
That's theory but in practice it doesn't work. I manually written myself an .elf executable where I request a block of memory starting at virtual address 0 where the program space is supposed to be, and it doesn't work. The first page is dysfunctional under Linux, because they distrust their own code so much that they unmap the first page there to catch NULL pointer dereferences in the kernel. I didn't program in C (I typed in ARM64 machine code directly in a hex editor) so they shouldn't push their particular programming language conventions or prejudices on me. ARM64 machine code doesn't have any NULL pointers. When I moved the things one page up, it started working. In other words, Linux does the mapping of the first page wrong. It should be mapped into RAM, because requested so in the .ELF file.
@williamdrum9899
@williamdrum9899 Жыл бұрын
I had the opposite problem where I was trying to make a GBA game in C and the linker kept putting the "cartridge" at $00000000 when it should be at $08000000
@timng9104
@timng9104 Жыл бұрын
can we take a look at PassKey announced by Apple and maybe Google, Windows soon. hardware security primitives what are they?
Multithreading Code - Computerphile
15:54
Computerphile
Рет қаралды 377 М.
Apple M1 Ultra & NUMA - Computerphile
15:24
Computerphile
Рет қаралды 254 М.
CAN YOU HELP ME? (ROAD TO 100 MLN!) #shorts
00:26
PANDA BOI
Рет қаралды 34 МЛН
Indian sharing by Secret Vlog #shorts
00:13
Secret Vlog
Рет қаралды 40 МЛН
But, what is Virtual Memory?
20:11
Tech With Nikola
Рет қаралды 176 М.
How does Computer Memory Work? 💻🛠
35:33
Branch Education
Рет қаралды 3,6 МЛН
What is virtual memory? - Gary explains
11:28
Android Authority
Рет қаралды 293 М.
Cracking Enigma in 2021 - Computerphile
21:20
Computerphile
Рет қаралды 2,4 МЛН
Cookie Stealing - Computerphile
16:12
Computerphile
Рет қаралды 1,1 МЛН
Reverse Engineering - Computerphile
19:49
Computerphile
Рет қаралды 182 М.
How WiFi Works - Computerphile
17:19
Computerphile
Рет қаралды 196 М.
M2 Mac - 8GB vs 16GB RAM - Avoid This Costly Mistake!
4:19
Chris Tomshack
Рет қаралды 2,1 МЛН
OS Context Switching - Computerphile
14:49
Computerphile
Рет қаралды 109 М.