Question

I have been reading about memory mapped files which allows file to be shared across multiple processes.

Every process (32 bit to be specific) has 4GB of private address space which is divided into 2GB of user mode address space and 2GB reserved for kernel as described here by Eric Lippert. User mode address space is private to each process and can't be modified by other process.

So, does that mean MMF's are mapped into kernel mode address space since it's shared across all processes?

I have searched a lot about MMF where it gets mapped but could not locate any resource stating that. So, posting question here if my assumption is right or I am missing something here? Any resource to MSDN would be good as well.

Was it helpful?

Solution

Memory mapped files are mapped into user-mode address space.

Think about it this way. Suppose you have a 4K file that is memory-mapped into two processes. This simply means that the one storage page on disk is associated with a particular page of virtual address space in each of two processes.

Diagram 3 on this page might help:

http://msdn.microsoft.com/en-us/library/ms810613.aspx

OTHER TIPS

A process does not have access to kernel address space. To a process the upper 2GB are just inaccessible for a reason unknown to it.

Memory mappings go into the user-mode portion of the address space.

Thanks to virtual memory hardware, physical pages can be present in multiple processes.

Private memory is not shared although all of it sits in the user-mode address range. Memory mappings are treated specially by the kernel. it instructs the hardware to make the physical pages available to multiple processes. Private memory is really a special case where the pages just happen to be mapped into one process only. The hardware doesn't care. In fact, you can have the same page mapped multiple times into the same process if you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top