369
95
/* create failed so open a remote pool */
96
assert(errno == EEXIST);
97
rpp = rpmem_open(target, poolset, pool, pool_size, &nlanes,
&pool_attr);
98
assert(rpp != NULL);
99
*created = 0;
100
101
return rpp;
102
}
• Line 88: A remote memory pool can be either created or opened.
When it is used for the first time, it must be created so that it is
available for the opening afterward. We first try to create it here.
• Line 97: Here we attempt to open the remote memory pool. We
assume it exists because of the error code received during the create
try (EEXIST).
Execution Example
The Hello World application produces the output shown in Listing 18-5.
Listing 18-5. An output from the Hello World application for librpmem
[user@initiator]$ ./hello
Hello world!
[user@initiator]$ ./hello
¡Hola Mundo!
Listing 18-6 shows the contents of the target persistent memory pool where we see
the “Hola Mundo” string.
Listing 18-6. The ¡Hola Mundo! snooped on the replication target
[user@target]$ hexdump –s 4096 –C /mnt/pmem1/pool2
00001000 01 00 00 00 c2 a1 48 6f 6c 61 20 4d 75 6e 64 6f |......Hola
Mundo|
00001010 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 |!...............|
Chapter 18 remote persistent memory
Précédent

- 392/457

Suivant