35
These persistent memory-aware file systems continue to present the familiar,
standard file APIs to applications including the open, close, read, and write system
calls. This allows applications to continue using the familiar file APIs while benefiting
from the higher performance of persistent memory.
Memory-Mapped Files
Before describing the next operating system option for using persistent memory,
this section reviews memory-mapped files in Linux and Windows. When memory
mapping a file, the operating system adds a range to the application’s virtual
address space which corresponds to a range of the file, paging file data into physical
memory as required. This allows an application to access and modify file data as
byte-addressable in-memory data structures. This has the potential to improve
performance and simplify application development, especially for applications that
make frequent, small updates to file data.
Applications memory map a file by first opening the file, then passing the resulting
file handle as a parameter to the mmap() system call in Linux or to MapViewOfFile() in
Windows. Both return a pointer to the in-memory copy of a portion of the file. Listing 3-1
shows an example of Linux C code that memory maps a file, writes data into the file
by accessing it like memory, and then uses the msync system call to perform the I/O
Figure 3-3. Persistent memory-aware file system
Chapter 3 Operating SyStem SuppOrt fOr perSiStent memOry
Précédent

- 64/457

Suivant