MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / reader

Function reader

test/shared-memory1.c:53–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53void
54reader(int fd)
55{
56 int *sharedMemory;
57 ATOMIC_SHARED int val;
58 int i;
59
60 sharedMemory = mmap(0, sizeof(int), PROT_READ, MAP_SHARED, fd, 0);
61 if (sharedMemory == MAP_FAILED) {
62 perror("mmap");
63 exit(1);
64 }
65 for (i = -1;;) {
66 val = *sharedMemory;
67 if (val > i) {
68 i = *sharedMemory;
69 printf("%d ", i);
70 fflush(stdout);
71 }
72 sleep(1);
73 }
74}
75
76void
77writer(int fd)

Callers 1

mainFunction · 0.70

Calls 2

mmapFunction · 0.70
sleepFunction · 0.50

Tested by

no test coverage detected