Is there an api to do memory mapping, just like
mmap()
on linux?
Windows doesn't have mmap , but it does have MapViewOfFile . Both of these implement memory mapped files, but there's one important difference: Windows keeps a lock on the file, not allowing it to be deleted. Even with the Windows flag FILE_SHARE_DELETE deletion does not work.
Memory mapping is one of the most interesting features of a Unix system. From a driver's point of view, the memory-mapping facility allows direct memory access to a user space device. To assign a mmap() operation to a driver, the mmap field of the device driver's struct file_operations must be implemented.
A memory-mapped file contains the contents of a file in virtual memory. This mapping between a file and memory space enables an application, including multiple processes, to modify the file by reading and writing directly to the memory.
What Is Memory-Mapping? Memory-mapping is a mechanism that maps a portion of a file, or an entire file, on disk to a range of addresses within an application's address space. The application can then access files on disk in the same way it accesses dynamic memory.
Depends on what exactly you want to use it for. If you want to map existing files into memory, that's supported with memory-mapped files. They can also be used to share memory between processes (use named mapping object with no underlying file). If you want to map physical memory, that's generally not supported from user mode, although there are some tricks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With