What's Virtual Memory? - Computerphile

Поділитися
Вставка
  • Опубліковано 1 гру 2024

КОМЕНТАРІ • 319

  • @Richardincancale
    @Richardincancale 2 роки тому +292

    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 2 роки тому +2

      this is a content channel, just something for clicks

    • @guywiththebottle
      @guywiththebottle 2 роки тому +3

      I wish I understand more of the differences between the different types of memory management.

    • @maxpower7086
      @maxpower7086 2 роки тому +12

      Nice explanation dude. I'll add that to my ever expanding block of computer knowledge.

    • @dannystoll84
      @dannystoll84 2 роки тому +3

      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 2 роки тому +10

      @@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.____.....__...__ 2 роки тому +116

    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. 2 роки тому +5

      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 2 роки тому +3

      @@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 2 роки тому +1

      I've wondered about this.. does this mean a buffer overflow is impossible then?

    • @TheBrainn
      @TheBrainn 2 роки тому

      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 2 роки тому +1

      @@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.

  • @JustFamilyPlaytime
    @JustFamilyPlaytime 2 роки тому +697

    Someone take away his pastel coloured markers and give him a black pen - then we'd be able to see his diagrams!

    • @bentoth9555
      @bentoth9555 2 роки тому +62

      Orange highlighter on white paper was an awful decision.

    • @zaphodbeeblebrox1695
      @zaphodbeeblebrox1695 2 роки тому +15

      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 2 роки тому +11

      Hard words but justified

    • @bentoth9555
      @bentoth9555 2 роки тому +5

      @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.

    • @blob537
      @blob537 2 роки тому +7

      Yeah, that was disappointing because Steve's videos are always so good, but it's so hard to see those diagrams.

  • @stensoft
    @stensoft 2 роки тому +76

    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 2 роки тому +4

      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 2 роки тому +15

      @@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 2 роки тому +7

      @@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 2 роки тому +5

      And this is the comment Steve wanted.

    • @JoeRobertshaw
      @JoeRobertshaw 3 місяці тому +1

      Well done everybody. As soon as he said it I started scrolling, and I (and I expect, Steve), was not disappointed

  • @Danny-hj2qg
    @Danny-hj2qg 2 роки тому +14

    I've had the question in the title of this video for numerous years. Thank you Computerphile.

  • @davidmurphy563
    @davidmurphy563 2 роки тому +131

    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 2 роки тому +6

      42.

    • @adamsbja
      @adamsbja 2 роки тому +13

      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 2 роки тому +5

      @@lordplenty Thanks for all the fish.

  • @ZacharyVogt
    @ZacharyVogt 2 роки тому +40

    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 2 роки тому +34

    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 2 роки тому +2

    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 2 роки тому +8

    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 2 роки тому +35

    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 2 роки тому +5

      I can still remember writing 6502 code all in hex for the C64. No assembler.

    • @ralfbaechle
      @ralfbaechle 2 роки тому +3

      @@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 2 роки тому +1

      @@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 2 роки тому

      @Ralf Baechle
      ORG 0C00
      EE 20 D0 4C 00 0C

    • @williamdrum9899
      @williamdrum9899 2 роки тому +2

      @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!

  • @sharpfang
    @sharpfang 2 роки тому +30

    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 2 роки тому +3

      I guess you would call them registers at this point, or is there any reason not to?

    • @sharpfang
      @sharpfang 2 роки тому +2

      @@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 2 роки тому

      @@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 2 роки тому +4

      @@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 2 роки тому +1

      @@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)

  • @marksterling8286
    @marksterling8286 2 роки тому +30

    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 2 роки тому +5

      If it was Solaris then it's absolutely normal (standard) that it does non-logical things :-)

    • @RonJohn63
      @RonJohn63 2 роки тому +3

      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 2 роки тому +1

      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 2 роки тому +2

      @@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 2 роки тому +3

      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.

  • @simplyacatenjoyinglife3260
    @simplyacatenjoyinglife3260 2 роки тому +1

    Who makes these thumbnails? That person needs a raise.

  • @Dayanto
    @Dayanto 2 роки тому +2

    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.

  • @pistonsjem
    @pistonsjem 2 роки тому +15

    finally i can leave hundreds of tabs open on my ipad exactly like my pc

    • @Roxor128
      @Roxor128 2 роки тому +2

      I wish I only had hundreds open!

  • @tracygilmore7983
    @tracygilmore7983 2 роки тому +5

    Guuyyyys, give the man a high contrast marker so we can see what he draws.

  • @mattthe2nd865
    @mattthe2nd865 2 роки тому +12

    Virtual memory makes me think of "downloading more ram".

    • @ohwow2074
      @ohwow2074 2 роки тому

      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.

  • @williamdrum9899
    @williamdrum9899 2 роки тому +8

    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.

  • @InquisitiveUniverse
    @InquisitiveUniverse 2 роки тому +2

    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.

  • @TheOriginalJohnDoe
    @TheOriginalJohnDoe 2 роки тому +2

    Starting the weekend well!

  • @phasm42
    @phasm42 2 роки тому +5

    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 2 роки тому

      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

  • @Mythilt
    @Mythilt 2 роки тому +9

    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.

  • @c1ph3rpunk
    @c1ph3rpunk 2 роки тому +12

    Ben Eater’s 8-bit computer, 16 bytes, hello world works.

    • @samuel7998
      @samuel7998 2 роки тому +1

      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 2 роки тому +1

      @@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 2 роки тому

      @@jope4009 actually they talk about the accumulator size. Lookup 8086 vs 8088. Same 16bit cpu except for databus.

  • @ysakhno
    @ysakhno 2 роки тому +9

    "of course 16 byte CPU wouldn't be much use for anything" -- the guy obviously hasn't heard of Ben Eater

  • @ΝίκοςΙστοσελίδα
    @ΝίκοςΙστοσελίδα 2 роки тому +5

    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 2 роки тому

      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.

    • @ΝίκοςΙστοσελίδα
      @ΝίκοςΙστοσελίδα 2 роки тому

      @@framegrace1 Still, that doesn't change the fact that multilevel translation does happen.

  • @sharkie115
    @sharkie115 2 роки тому +2

    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 2 роки тому

      You can also have virtual swap via zram!

  • @augustovasconcellos7173
    @augustovasconcellos7173 2 роки тому +2

    This video would have been *really* useful to me a week ago when I was having my OS finals

  • @andreasklindt7144
    @andreasklindt7144 2 роки тому +5

    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 2 роки тому +2

      The risk can be mitigated, but yes, see the swap-digger tool for example.

    • @d5uncr
      @d5uncr 2 роки тому +6

      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 2 роки тому

      If you can read the swap file, you can also read the swap partition, but also read the memory directly.

    • @majorgnu
      @majorgnu 2 роки тому

      @@d5uncr That's why applications should keep their secrets in mlock'd memory.
      See: man 2 mlock

  • @MyzaZoo555
    @MyzaZoo555 2 роки тому +3

    So it's kinda like a hashtable but for hardware?

  • @McDuffington
    @McDuffington 2 роки тому +1

    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.

  • @MountainKing123
    @MountainKing123 2 роки тому +8

    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 Рік тому

      Have you found any? I'm in the same boat, can't seem to find some solid information on GPUs

  • @congenio
    @congenio 2 роки тому +3

    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 2 роки тому +7

    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 2 роки тому +9

      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 2 роки тому +4

      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.

  • @trelligan42
    @trelligan42 2 роки тому +2

    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).

  • @DanielJStahl
    @DanielJStahl 2 роки тому +3

    Orange highlighter might not have been the best choice

  • @yaiirable
    @yaiirable 2 роки тому +7

    Can I finally download more RAM?

  • @andljoy
    @andljoy 2 роки тому +14

    I am more shocked iOS did not support swap/virtual memory/page before now.

    • @funposting8912
      @funposting8912 2 роки тому

      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 2 роки тому

      RIght! What is this Apple System 7.5?

    • @Acorn_Anomaly
      @Acorn_Anomaly 2 роки тому +2

      I think they did, but at an OS/program level, not app level. Same as Android.

    • @sub-harmonik
      @sub-harmonik 2 роки тому

      .. did you watch the whole video?

  • @crcrewso
    @crcrewso 2 роки тому +7

    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 2 роки тому

      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 2 роки тому

      AFAIK, this all comes from how kernels handle the MMU, not MMU itself or having multiple MMU's.

  • @j7ndominica051
    @j7ndominica051 2 роки тому +2

    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 2 роки тому

      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.

  • @johnsenchak1428
    @johnsenchak1428 2 роки тому +3

    Can you do a video on Microsoft patches and how they protect the computers from vulnerabilities

    • @Faladrin
      @Faladrin 2 роки тому

      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 2 роки тому

      @@Faladrin More specially what it means by remote code execution, elevation of privileged , security bypass

  • @christopherg2347
    @christopherg2347 2 роки тому

    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.

  • @kikodekliko1209
    @kikodekliko1209 2 роки тому +1

    How many layers of abstraction are possible before nobody in the world actually understands how a computer or application works?

  • @primordial_platypus
    @primordial_platypus 2 роки тому +3

    Didn’t IBM do an early version of this in the 1960’s.

    • @quintrankid8045
      @quintrankid8045 2 роки тому

      Yes and some earlier systems had virtual memory as well.

  • @cidercreekranch
    @cidercreekranch 2 роки тому +5

    Segmented addressing. Never mention that again! :)

    • @nHans
      @nHans 2 роки тому +1

      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._ 👻

  • @briancoverstone4042
    @briancoverstone4042 2 роки тому

    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?

  • @Gooberpatrol66
    @Gooberpatrol66 2 роки тому +62

    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 2 роки тому +6

      if it works for the normies then that's all it needs.

    • @Freshbott2
      @Freshbott2 2 роки тому +7

      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 2 роки тому +1

      @@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 6 місяців тому

      @@Freshbott2 another Apple fanboy

  • @47Mortuus
    @47Mortuus Рік тому +1

    2:29 Am I high? (The marker)

  • @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.

  • @mausmalone
    @mausmalone 2 роки тому

    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 2 роки тому +3

    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 2 роки тому +2

      Virtual Pen needed to be swapped out for a real pen.

    • @landsgevaer
      @landsgevaer 2 роки тому

      Chain paper: "what did I do wrong?"

  • @JATmatic
    @JATmatic 2 роки тому +1

    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.

  • @cthutu
    @cthutu 2 роки тому +4

    Let's not use a orange marker pen ever again :)

  • @putrescentvermin
    @putrescentvermin 2 роки тому

    Virtual memory is backup RAM for when you play modern videogames like Warzone on an 8GB PC at the cost of fps.

  • @Amonimus
    @Amonimus 2 роки тому +1

    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 2 роки тому

      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)

  • @jeffburrell7648
    @jeffburrell7648 2 роки тому +8

    Wowzer!! Apple is advancing into the 1990s! Truly magical.

  • @LanceMcCarthy
    @LanceMcCarthy 2 роки тому +1

    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 2 роки тому +2

      You could do Hello World with 1 byte or even less.
      You just need an ISA with a dedicated Hello World instruction :P

  • @romanboman3847
    @romanboman3847 2 роки тому

    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?

  • @soraaoixxthebluesky
    @soraaoixxthebluesky Рік тому

    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 2 роки тому +1

    Steve has the coolest shirt on

    • @dericn
      @dericn 2 роки тому

      and it has very strong buttons!

  • @MacHooolahan
    @MacHooolahan 2 роки тому +3

    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 2 роки тому +4

      They didn't say paging was new.

    • @MacHooolahan
      @MacHooolahan 2 роки тому

      @@ChrisLee-yr7tz Indeed they didn't.

  • @hedgehog125
    @hedgehog125 2 роки тому +1

    Is there also wear levelling for RAM? And does that use a second virtual memory lookup?

    • @Acorn_Anomaly
      @Acorn_Anomaly 2 роки тому +2

      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 2 роки тому +5

      No wear leveling for RAM.

    • @StephenHoldaway
      @StephenHoldaway 2 роки тому +7

      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 2 роки тому

      There is no wear levelling for RAM.

  • @misterhat5823
    @misterhat5823 2 роки тому

    I've done plenty of things in assembly in embedded applications using 16 bytes or less. So it certainly isn't useless.

  • @H4x4t3hN00bz
    @H4x4t3hN00bz 2 роки тому

    How much delay does virtual memory introduce versus accessing memory directly?

    • @compuholic82
      @compuholic82 2 роки тому +3

      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.

  • @AmitYadav-rp3ot
    @AmitYadav-rp3ot 10 місяців тому

    Great video!!!

  • @TheInternetHelpdeskPlays
    @TheInternetHelpdeskPlays 2 роки тому +24

    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 2 роки тому +11

      The new IPad Pro, now running on an i286.

    • @bilboswaggings
      @bilboswaggings 2 роки тому +2

      Yeah, even phones have it now

    • @andljoy
      @andljoy 2 роки тому +4

      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 2 роки тому +6

      Where do they pretend this is a new thing?

    • @MsNerthul
      @MsNerthul 2 роки тому

      @@wearwolf2500 segmented memory.. Yeah!! ;)

  • @vootkidss2704
    @vootkidss2704 2 роки тому

    I think that safety is important and one should use double-protection technologies, such as Oreol Staking!

  • @davidhutchinson88
    @davidhutchinson88 2 роки тому

    Couldn't follow along with the yellow marker on white paper, very hard to read

  • @brandonlink6568
    @brandonlink6568 2 роки тому +1

    The opposite of this is a RAM drive but with 12 terabyte hard drives being economical they don't get much use anymore

  • @bolagadalla
    @bolagadalla 2 роки тому

    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 2 роки тому +2

      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 2 роки тому

      @@trelligan42 thank you for the clarification. I Appreciate it.

  • @tyrport
    @tyrport 2 роки тому

    4K is the largest amount you can do 16 bit CRC with.

  • @pilotandy_com
    @pilotandy_com 2 роки тому

    Isn’t that essentially what mmap in c is doing?

  • @Lion_McLionhead
    @Lion_McLionhead 2 роки тому +1

    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.

  • @LimeGreenTeknii
    @LimeGreenTeknii 2 роки тому +2

    I can print "Hello world" in one byte. Build a computer that prints "Hello world" if its byte is 1, and does not print "Hello world" if its byte is 0.

    • @charlieangkor8649
      @charlieangkor8649 2 роки тому +2

      Make a LED lamp with a "Hello World" mask on it and turn it one with 1 bit

  • @rynoopperman5010
    @rynoopperman5010 2 роки тому

    VMware virtualisation / MS hypervisor
    Mapping changes all the time cause DRS moves workloads around and re-registeres virtual memory continuously

  • @patheally
    @patheally 2 роки тому

    Is this available on the M1 chip?

  • @alexrossouw7702
    @alexrossouw7702 2 роки тому

    Highlighters are supposed to be the most visible pen

  • @nonsuch
    @nonsuch 2 роки тому

    That's a pretty trippy marker! I want one! 😛😉

  • @SirHackaL0t.
    @SirHackaL0t. 2 роки тому

    Fyi, orange highlighter is not the best choice for showing info on paper.

  • @ConnorKennedy16
    @ConnorKennedy16 2 роки тому

    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

  • @SergeMatveenko
    @SergeMatveenko 2 роки тому

    Oh my! That pen...

  • @sushanshakya
    @sushanshakya 2 роки тому

    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 2 роки тому +3

      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.

  • @AboveEmAllProduction
    @AboveEmAllProduction 2 роки тому +6

    Highlighter not the best pen 😀

  • @xion1305
    @xion1305 2 роки тому +1

    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.

  • @jeffjiang5272
    @jeffjiang5272 2 роки тому +2

    I can finally download more RAM

  • @antoniopetito
    @antoniopetito 2 роки тому

    I like living on the edge and disable paging.

  • @lammatt
    @lammatt 2 роки тому +1

    Download more ram?

  • @TheSudsy
    @TheSudsy 2 роки тому +1

    The opposite of RAM disc.

  • @ericsimaginaryfriend
    @ericsimaginaryfriend 2 роки тому +2

    Nice

  • @bradyblough
    @bradyblough 2 роки тому

    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.

  • @aw34565
    @aw34565 2 роки тому

    10PRINT"HELLO WORLD" on my BBC Micro takes 20 bytes (The difference between TOP and PAGE).

  • @williamfarris796
    @williamfarris796 2 роки тому +1

    I just download more RAM when I run out

  • @johhue
    @johhue 2 роки тому

    I am colorblind. Cannot see any of these diagrams.

  • @tristanrogers1780
    @tristanrogers1780 2 роки тому

    Virtual memory is the best

  • @johnnyblue4799
    @johnnyblue4799 Рік тому

    I haven't seen perforated printer paper in ages...

  • @skyscraperfan
    @skyscraperfan 2 роки тому +3

    Don't SSDs have quite a limited number of write cycles? Imagine you really use virtual memory for video editing. Then you have to copy a lot of data onto the SSD very often. Of course the SSD controller will make sure that the data is spread among all areas of the SDD to avoid using a single area too often, but if there are only a few GB of space left on the SSD, there still is the danger that it has to write on the same area again unless the controller moves the existing data once in a while. Still I would like to keep amount of write cycles as small as possible, if that is the same SSD that also contains important data.

    • @hoagy_ytfc
      @hoagy_ytfc 2 роки тому +1

      Modern SSDs have a lot of write cycles. It’s not a problem for the lifetime of an iPad. And swap is only implemented in M1-based iPads that have a lot of ram anyway.

  • @murtadhaaldulaimi4825
    @murtadhaaldulaimi4825 2 роки тому

    LFG if you don’t work with Oreol Staking provider yet

  • @steamrangercomputing
    @steamrangercomputing Рік тому

    Is it just me or does apple sound really outdated? Like in this video virtual memory is mentioned as a new thing on iPads, and in another video a modern looking Mac was mentioned as having a 2 core cpu. Both of these things have been popular since the early 2000s.

  • @abeachristine5446
    @abeachristine5446 2 роки тому

    Do this damage ssd

  • @charlieangkor8649
    @charlieangkor8649 2 роки тому

    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 2 роки тому

      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