Synchronuos start of many instances of the same process

Suppose you need to start 5 instances of the same process simultaneously. There are no problems until those process does not use resources exclusively. For example they are trying to write to the same log file at the same time:

config1.GIF

In this case you will need to synchronize them in a some way. You may want to make those processes to run some sections of code in a mutually exclusive mode:

config2.GIF

 This may be naturally achieved by introducing a mutex synchronization. The sample below shows this approach on practice: mutex.zip

To see the results start several instances of this application at the same time, and the release mutex lock by pressing any key on the application’s console. You will see how other processes will react on this event:

synchronizedstart.JPG

Bookmark and Share

Leave a Reply

Add Webcam or
Audio-only Comment