<< prev | next >> |
This example shows how to write to shared memory using the Shared Memory Arena library.
We already ran this program in the last example in Reading Shared Memory Segments.
From the source file examples/tutorial/write.c
First we include some header files:
We have a main function:
We get some a shared memory just like in the read example:
We initialize the shared memory while holding a segment write lock:
We then loop: write-locking, writing, unlocking, and sleeping until the count in shared memory is greater than 10:
<< prev | next >> |