How to control and synchronize concurrent code execution

network_sat

Estimable
Jul 10, 2015
8
0
4,510
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
 
Solution
You would have to use some type of synchronization. You would use semaphores, or spinlocks, or other constructs. Each program that has a section that is dependent on the other would attempt to establish some type of lock which would prevent the other program from executing code which could conflict. If the second program is doing something independent it would continue. When it gets to an area in code that could conflict the lock would prevent it from progressing until the first application released the lock. Then the second program would establish the lock to prevent the first program from interfering. There are lots of tutorials on thread synchronization. The concepts are the same although the implementation might be slightly...

kanewolf

Judicious
Moderator
You would have to use some type of synchronization. You would use semaphores, or spinlocks, or other constructs. Each program that has a section that is dependent on the other would attempt to establish some type of lock which would prevent the other program from executing code which could conflict. If the second program is doing something independent it would continue. When it gets to an area in code that could conflict the lock would prevent it from progressing until the first application released the lock. Then the second program would establish the lock to prevent the first program from interfering. There are lots of tutorials on thread synchronization. The concepts are the same although the implementation might be slightly different with two executables.
 
Solution