How to control and synchronize concurrent code execution

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
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
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?
thanks a lot,
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.
nice info to know
Topic archived. No new replies allowed.