Memory mapping of files and other resources, and paging more generally, needs to take into consideration the following requirements:
Access to specific regions of resources, exposing them via flexpages
Sharing of flexpages between regions so that data is only loaded once
Avoidance of overlapping flexpages
Pagers are involved in memory mapping to provide the memory pages that appear within the memory areas exposing portions of resources. They rely on collections of pages so that they may supply populated pages. To populate pages, pagers employ accessors which have the necessary knowledge to obtain data for a particular resource.
A page collection is an area of virtual memory backed by physical memory that is made available for files and other resources. Pages are allocated to files on request, with allocation occurring only if no existing allocated pages happen to satisfy a given map request.
Once allocated, pages are populated by pagers, and page details are sent as map items to tasks needing to access them. When pages are no longer needed, they are flushed and invalidated.
When no free pages are available to satisfy a request, an existing page will be flushed and recycled for the new request.
Accessors provide the functionality needed by pagers to populate pages with the data requested from within a region of a resource. Two operations are supported for handling data with flexpages:
fill_flexpage_data
flush_flexpage_data
These operations depend on specific implementations of the following operations:
read
write
Since each accessor operates within the context of a particular file, concurrency control is likely to be enforced at this level to prevent competing concurrent accesses to the filesystem data representing the file.
Filesystem objects are provided using file resource abstractions, with memory-mapped objects employing a generic mapped file resource abstraction in combination with a filesystem-specific accessor and a generic page collection.