227
45
_mm_clflush((char *)uptr);
46 }
47
48 int main(int argc, char *argv[]) {
49
int fd, *ptr, *data, *flag;
50
51
fd = open("/mnt/pmem/file", O_CREAT|O_RDWR, 0666);
52
posix_fallocate(fd, 0, sizeof(int) * 2);
53
54
ptr = (int *) mmap(NULL, sizeof(int) * 2,
55
PROT_READ | PROT_WRITE,
56
MAP_SHARED_VALIDATE | MAP_SYNC,
57
fd, 0);
58
59
data = &(ptr[1]);
60
flag = &(ptr[0]);
61
*data = 1234;
62
flush((void *) data, sizeof(int));
63
*flag = 1;
64
flush((void *) flag, sizeof(int));
65
66
munmap(ptr, 2 * sizeof(int));
67
return 0;
68 }
Listing 12-20 executes Persistence Inspector against the modified code from
Listing 12-19, then the reader code from Listing 12-15, and finally running the report,
which says that no problems were detected.
Listing 12-20. Running full analysis with Intel Inspector – Persistence Inspector
with code Listings 12-19 and 12-15
$ pmeminsp cb -pmem-file /mnt/pmem/file -- ./listing_12-19
++ Analysis starts
++ Analysis completes
++ Data is stored in folder "/data/.pmeminspdata/data/listing_12-19"
Chapter 12 Debugging persistent MeMory appliCations
Précédent

- 251/457

Suivant