Skip to content

Commit 72b597c

Browse files
committed
Use UMF_MEM_MAP_SYNC for FSDAX in the FSDAX IPC example
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 885c9d2 commit 72b597c

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

test/ipc_file_prov_consumer.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
*/
77

8+
#include <stdbool.h>
89
#include <stdio.h>
910
#include <stdlib.h>
11+
#include <strings.h>
1012

1113
#include <umf/providers/provider_file_memory.h>
1214

@@ -15,17 +17,30 @@
1517

1618
int main(int argc, char *argv[]) {
1719
if (argc < 3) {
18-
fprintf(stderr, "usage: %s <port> <file_name>\n", argv[0]);
20+
fprintf(stderr, "usage: %s <port> <file_name> <fsdax>\n", argv[0]);
21+
fprintf(stderr, " <fsdax> should be \"FSDAX\" or \"fsdax\" if "
22+
"<file_name> is located on FSDAX \n");
1923
return -1;
2024
}
2125

2226
int port = atoi(argv[1]);
2327
char *file_name = argv[2];
28+
bool is_fsdax = false;
29+
30+
if (argc >= 4) {
31+
if (strncasecmp(argv[3], "FSDAX", strlen("FSDAX")) == 0) {
32+
is_fsdax = true;
33+
}
34+
}
2435

2536
umf_file_memory_provider_params_t file_params;
2637

2738
file_params = umfFileMemoryProviderParamsDefault(file_name);
28-
file_params.visibility = UMF_MEM_MAP_SHARED;
39+
if (is_fsdax) {
40+
file_params.visibility = UMF_MEM_MAP_SYNC;
41+
} else {
42+
file_params.visibility = UMF_MEM_MAP_SHARED;
43+
}
2944

3045
return run_consumer(port, umfFileMemoryProviderOps(), &file_params, memcopy,
3146
NULL);

test/ipc_file_prov_fsdax.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes"
2525
rm -f ${FILE_NAME}
2626

2727
echo "Starting ipc_file_prov_fsdax CONSUMER on port $PORT ..."
28-
UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_consumer $PORT $FILE_NAME &
28+
UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_consumer $PORT $FILE_NAME "FSDAX" &
2929

3030
echo "Waiting 1 sec ..."
3131
sleep 1
3232

3333
echo "Starting ipc_file_prov_fsdax PRODUCER on port $PORT ..."
34-
UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_producer $PORT $FILE_NAME
34+
UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_producer $PORT $FILE_NAME "FSDAX"
3535

3636
# remove the SHM file
3737
rm -f ${FILE_NAME}

test/ipc_file_prov_producer.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
*/
77

8+
#include <stdbool.h>
89
#include <stdio.h>
910
#include <stdlib.h>
11+
#include <strings.h>
1012

1113
#include <umf/providers/provider_file_memory.h>
1214

@@ -15,17 +17,30 @@
1517

1618
int main(int argc, char *argv[]) {
1719
if (argc < 3) {
18-
fprintf(stderr, "usage: %s <port> <file_name>\n", argv[0]);
20+
fprintf(stderr, "usage: %s <port> <file_name> <fsdax>\n", argv[0]);
21+
fprintf(stderr, " <fsdax> should be \"FSDAX\" or \"fsdax\" if "
22+
"<file_name> is located on FSDAX \n");
1923
return -1;
2024
}
2125

2226
int port = atoi(argv[1]);
2327
char *file_name = argv[2];
28+
bool is_fsdax = false;
29+
30+
if (argc >= 4) {
31+
if (strncasecmp(argv[3], "FSDAX", strlen("FSDAX")) == 0) {
32+
is_fsdax = true;
33+
}
34+
}
2435

2536
umf_file_memory_provider_params_t file_params;
2637

2738
file_params = umfFileMemoryProviderParamsDefault(file_name);
28-
file_params.visibility = UMF_MEM_MAP_SHARED;
39+
if (is_fsdax) {
40+
file_params.visibility = UMF_MEM_MAP_SYNC;
41+
} else {
42+
file_params.visibility = UMF_MEM_MAP_SHARED;
43+
}
2944

3045
return run_producer(port, umfFileMemoryProviderOps(), &file_params, memcopy,
3146
NULL);

0 commit comments

Comments
 (0)