Programming Persistent Memory by Steve Scargall

Programming Persistent Memory by Steve Scargall

Author:Steve Scargall
Language: eng
Format: epub, pdf
ISBN: 9781484249321
Publisher: Apress


Nonpersistent Stores

Nonpersistent stores refer to data written to persistent memory but not flushed explicitly. It is understood that if the program writes to persistent memory, it wishes for those writes to be persistent. If the program ends without explicitly flushing writes, there is an open possibility for data corruption. When a program exits gracefully, all the pending writes in the CPU caches are flushed automatically. However, if the program were to crash unexpectedly, writes still residing in the CPU caches could be lost.

Consider the code in Listing 12-7 that writes data to a persistent memory device mounted to /mnt/pmem without flushing the data. 32 #include <stdio.h>

33 #include <sys/mman.h>

34 #include <fcntl.h>

35

36 int main(int argc, char *argv[]) {

37 int fd, *data;

38 fd = open("/mnt/pmem/file", O_CREAT|O_RDWR, 0666);

39 posix_fallocate(fd, 0, sizeof(int));

40 data = (int *) mmap(NULL, sizeof(int), PROT_READ |

41 PROT_WRITE, MAP_SHARED_VALIDATE |

42 MAP_SYNC, fd, 0);

43 *data = 1234;

44 munmap(data, sizeof(int));

45 return 0;

46 }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Linux Device Driver Development Cookbook by Rodolfo Giometti(3334)
Building Low Latency Applications with C++ by Sourav Ghosh(2608)
Fusion 360 for Makers by Lydia Sloan Cline(1977)
Networking A Beginner's Guide by Bruce Hallberg(1919)
But How Do It Know? by J. Clark Scott(1804)
Computers For Seniors For Dummies by Nancy C. Muir(1764)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1748)
Hands-On Linux for Architects by Denis Salamanca(1706)
Hack and HHVM by Owen Yamauchi(1666)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1657)
PrestaShop Recipes by Arnaldo Pérez Castaño(1460)
MicroPython Projects by Jacob Beningo(1429)
Hands-On Internet of Things with MQTT by Tim Pulver(1384)
Getting Started with Soldering: A Hands-On Guide to Making Electrical and Mechanical Connections by Vinck Marc de(1376)
Raspberry Pi Electronics Projects for the Evil Genius (Tab) by Norris Donald & Norris Donald(1376)
Embedded Systems Architecture by Daniele Lacamera(1369)
Healthcare Information Security and Privacy (All-In-One) by Sean Murphy(1364)
Shaping the Fourth Industrial Revolution by Klaus Schwab & Nicholas Davis & Satya Nadella(1352)
The Internet of Things (The MIT Press Essential Knowledge series) by Greengard Samuel(1342)
Raspberry Pi Beginners Guide: Ultimate Guide For Rasberry Pi, User guide To Get The Most Out Of Your Investment, Hacking, Programming, Python, Best Hardware, Beginners Guide To Rasberry Pi by Steven Giles(1329)