Memory Mapped Files: Difference between revisions
Yuron [PHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPmludGVyZmFjZS1hZG1pbjxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs) m (1 revision imported) |
pc>Yuron No edit summary |
||
Line 1: | Line 1: | ||
{{#set: Priority=2 | Summary=Gaining access to files by <i>making them appear</i> as arrays in the address space.}}<!-- | {{#set: Priority=2 | Summary=Gaining access to files by <i>making them appear</i> as arrays in the address space.}}<!-- | ||
-->{{#invoke:Dependencies|add|File Access,3|Memory,2}} | -->{{#invoke:Dependencies|add|File Access,3|Memory,2}} | ||
A method of [[File_Access|file access]], [https://en.wikipedia.org/wiki/memory-mapped_file memory mapping] a file (or | A method of [[File_Access|file access]], [https://en.wikipedia.org/wiki/memory-mapped_file memory mapping] a file (or device) is a way of making the file <strong>appear</strong> in a process’ virtual address space. This is not necessarily as comprehensive as the more traditional [[File_Access|file access methods]] – note that all the opened files need to fit in the process’ space and, sometimes, files are <em>large</em> (though with the advent of 64-bit address spaces on larger machines this will probably be less of a problem … at least for a few years). On the other hand it can be convenient to use and will typically be significantly faster than making sets of system calls. | ||
device) is a way of making the file <strong>appear</strong> in a process’ virtual | |||
address space. This is not necessarily as comprehensive as the more | |||
traditional [[File_Access|file access methods]] – note that all the | |||
opened files need to fit in the process’ space and, sometimes, files | |||
are <em>large</em> (though with the advent of 64-bit address spaces on larger | |||
machines this will probably be less of a problem … at least for a | |||
few years). On the other hand it can be convenient to use and will | |||
typically be significantly faster than making sets of system calls. | |||
Memory mapping a file on a virtual memory system does not mean the | Memory mapping a file on a virtual memory system does not mean the whole file is read into RAM! Usually a “lazy” approach | ||
whole file is read into RAM! Usually a “lazy” approach | will be used where only the appropriate [[Paging|pages]] will be fetched, on demand. This is basically the same demand paging | ||
will be used where only the appropriate [[Paging|pages]] will be | |||
fetched, on demand. This is basically the same demand paging | |||
mechanism used in virtual memory. | mechanism used in virtual memory. | ||
[[Image:mmap.png|link=|alt=Memory mapped files]] | [[Image:mmap.png|link=|alt=Memory mapped files]] | ||
There is a worked example of this process in the download <code>mmap</code>. | There is a worked example of this process in the download <code>mmap</code>. This contains quite a few obscure calls; the <em>important point</em> is the text from the file appears in an ordinary array. | ||
This contains quite a few obscure calls; the <em>important point</em> is the | |||
text from the file appears in an ordinary array. | |||
---- | ---- | ||
{{BookChapter|13.5|555-560}} | |||
{{PageGraph}} | {{PageGraph}} | ||
{{Category|Memory}} | {{Category|Memory}} | ||
{{Category|User}} | {{Category|User}} |
Revision as of 13:30, 2 August 2019
Depends on | File Access • Memory |
---|
A method of file access, memory mapping a file (or device) is a way of making the file appear in a process’ virtual address space. This is not necessarily as comprehensive as the more traditional file access methods – note that all the opened files need to fit in the process’ space and, sometimes, files are large (though with the advent of 64-bit address spaces on larger machines this will probably be less of a problem … at least for a few years). On the other hand it can be convenient to use and will typically be significantly faster than making sets of system calls.
Memory mapping a file on a virtual memory system does not mean the whole file is read into RAM! Usually a “lazy” approach will be used where only the appropriate pages will be fetched, on demand. This is basically the same demand paging mechanism used in virtual memory.
There is a worked example of this process in the download mmap
. This contains quite a few obscure calls; the important point is the text from the file appears in an ordinary array.
Also refer to: | Operating System Concepts, 10th Edition: Chapter 13.5, pages 555-560 |
---|