Your suggestion above is valid. That approach would work. It might be easier to use a chunk of shared memory and mutex instead, but it's ultimately your call. I've included a working example that uses pthread_mutex
calls and mmap
in the references below that should get you up and running. Good luck!
References
- C procs, fork(), and mutexes, Accessed 2014-04-29,
<https://stackoverflow.com/questions/19172541/procs-fork-and-mutexes>