How to control and synchronize concurrent code execution

Jul 13, 2015 at 8:37am
Hi.

Suppose I have two programs where some sections of the code of one program file depend on the some sections of other program. How can I make sure that the dependency is executed properly. I mean dependent section of one program does not execute faster than the section of other program which depends on the first program's section...

Thanks
Jul 13, 2015 at 8:52am
By use of interprocess synchronization mechanism
On Windows you can used named mutex. On POSIX systems you can use a dummy file and flock

Currently there is no generic way to do this in standard C++, you can use BOOST
http://www.boost.org/doc/libs/1_57_0/doc/html/interprocess/synchronization_mechanisms.html
Jul 13, 2015 at 11:23am
Thanks. What about posix system calls in C++ such as mutex, signal, lock etc? Does that work? or is that for threads only in the same process?
Jul 13, 2015 at 11:59am
Jul 15, 2015 at 4:26am
thanks a lot,
Jul 15, 2015 at 5:36am
For general thread you can (and should) use C++11 threads. Unfortunately C++11 does not support name mutexes.

This means you can use C++11 to synchronize threads of same process but not threads across processes. For that you have to rely on pthreads or Windows API.
Jul 16, 2015 at 8:04am
nice info to know
Topic archived. No new replies allowed.