Skip to content

Commit 1c709c7

Browse files
Merge pull request #766 from ldorau/Use_UMF_MEM_MAP_SYNC_for_FSDAX_in_the_FSDAX_IPC_example
Use UMF_MEM_MAP_SYNC for FSDAX in the FSDAX IPC example
2 parents 52e7da9 + e3b3e9e commit 1c709c7

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

test/ipc_file_prov_consumer.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
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 <string.h>
12+
#include <strings.h>
1013

1114
#include <umf/providers/provider_file_memory.h>
1215

@@ -15,17 +18,30 @@
1518

1619
int main(int argc, char *argv[]) {
1720
if (argc < 3) {
18-
fprintf(stderr, "usage: %s <port> <file_name>\n", argv[0]);
21+
fprintf(stderr, "usage: %s <port> <file_name> <fsdax>\n", argv[0]);
22+
fprintf(stderr, " <fsdax> should be \"FSDAX\" or \"fsdax\" if "
23+
"<file_name> is located on FSDAX \n");
1924
return -1;
2025
}
2126

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

2537
umf_file_memory_provider_params_t file_params;
2638

2739
file_params = umfFileMemoryProviderParamsDefault(file_name);
28-
file_params.visibility = UMF_MEM_MAP_SHARED;
40+
if (is_fsdax) {
41+
file_params.visibility = UMF_MEM_MAP_SYNC;
42+
} else {
43+
file_params.visibility = UMF_MEM_MAP_SHARED;
44+
}
2945

3046
return run_consumer(port, umfFileMemoryProviderOps(), &file_params, memcopy,
3147
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: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
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 <string.h>
12+
#include <strings.h>
1013

1114
#include <umf/providers/provider_file_memory.h>
1215

@@ -15,17 +18,30 @@
1518

1619
int main(int argc, char *argv[]) {
1720
if (argc < 3) {
18-
fprintf(stderr, "usage: %s <port> <file_name>\n", argv[0]);
21+
fprintf(stderr, "usage: %s <port> <file_name> <fsdax>\n", argv[0]);
22+
fprintf(stderr, " <fsdax> should be \"FSDAX\" or \"fsdax\" if "
23+
"<file_name> is located on FSDAX \n");
1924
return -1;
2025
}
2126

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

2537
umf_file_memory_provider_params_t file_params;
2638

2739
file_params = umfFileMemoryProviderParamsDefault(file_name);
28-
file_params.visibility = UMF_MEM_MAP_SHARED;
40+
if (is_fsdax) {
41+
file_params.visibility = UMF_MEM_MAP_SYNC;
42+
} else {
43+
file_params.visibility = UMF_MEM_MAP_SHARED;
44+
}
2945

3046
return run_producer(port, umfFileMemoryProviderOps(), &file_params, memcopy,
3147
NULL);

0 commit comments

Comments
 (0)