CS 134 OS-7: Memory-Mapped Files

Поделиться
HTML-код
  • Опубликовано: 8 янв 2025
  • Day # of Harvey Mudd College Operating Systems class

Комментарии • 23

  • @decomodus
    @decomodus 3 года назад +7

    This is the best explanation I've seen so far. Straight to the point
    NICE

  • @mikgol81
    @mikgol81 3 года назад +6

    You're like the Clint Eastwood of programmers

  • @sword013
    @sword013 4 года назад +3

    Sir how is this faster than directly writing onto the file on disk ? Here you page it in, then write on physical memory and then it eventually has to write back in disk, so how is this faster ?
    Sorry if this is a dumb question and I understand the queuing part but, in both cases, you need to move the disk read/write heads which is going to take up time. So ain't this more indirect and should take more time ?

    • @NeilRhodesHMC
      @NeilRhodesHMC  4 года назад +2

      The only speed increase is due to the fact that changes to the file don't require a system call. However, you're right that the pages need to be both read in and written out whether or not the file is memory-mapped.
      It provides a different interface for the application that may be more convenient. It can sometimes reduce the amount of copying that's done as well.

    • @maboesanman
      @maboesanman 3 года назад

      There are other benefits, like for example if you mount the file to the same address space every time, you can store self referential pointers directly in a file, and they’ll stay valid on subsequent loads of the file

  • @federicopueblalarregle5791
    @federicopueblalarregle5791 Год назад

    I understand that you can optionally `msync` your write if you want to ensure it's written back to disk, but as you mentioned otherwise is up to the kernel to decide when to write it back to disk. For this same reason, I understand that database engines try to avoid `mmap` since it could result in dirty writes or write before a transaction completes (if the kernel decides to write back to disk).
    Do you know what alternatives do they have to map files to memory without having to worry on the kernel writing them back to disk when the engine doesn't want to yet?
    Thanks in advance.

  • @miladin4023
    @miladin4023 4 года назад

    Neil thank you so much for this!

  • @oleholgerson3416
    @oleholgerson3416 2 года назад

    thank you so much for your videos!

  • @zeeshanparvez5235
    @zeeshanparvez5235 2 года назад

    Amazing explanation

  • @tsunghan_yu
    @tsunghan_yu 3 года назад

    Does mmap increase a process' address space? If not, which segment is it stored in the memory?

    • @NeilRhodesHMC
      @NeilRhodesHMC  3 года назад +1

      There's a flat address space and mmap must map somewhere within that address space. Before the mapping, trying to access memory at that address will cause a page fault (assuming it's unmapped). Afterwards, access will succeed.

  • @AugerHybrid
    @AugerHybrid 4 года назад +1

    Thanks for helping me on my programming course! Did you really write that all on glass and mirrored the video?

    • @NeilRhodesHMC
      @NeilRhodesHMC  4 года назад +8

      Yes. See ruclips.net/video/S-rDH4O5CsI/видео.html for a "Making of" video that shows the process in detail.

    • @lucas90gs
      @lucas90gs 2 года назад +1

      @@NeilRhodesHMC Loved this video format!

  • @rosarioscavo6791
    @rosarioscavo6791 4 года назад

    Great explanation!

  • @MrXperx
    @MrXperx 3 года назад

    very nice professor

  • @dushyantprakash1768
    @dushyantprakash1768 2 дня назад

    GOLD

  • @JulienBertozzi
    @JulienBertozzi 3 года назад

    Thanks !

  • @esmanlitebriz
    @esmanlitebriz 3 года назад +2

    hey uncle where does your voice coming from?I cant hear anything..pfff.lol

  • @dingxu4557
    @dingxu4557 3 года назад +1

    If only there were Chinese subtitles

  • @nexa7606
    @nexa7606 2 года назад

    5head

  • @DetectiveMar
    @DetectiveMar 3 месяца назад

    Thanks!