Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Would it be possible to run same c++ code simultaneously?

Say I compile some code and make it run. It will take 10 mins to finish. In the meantime, if I change some parameters in the code and compile it again using a separate terminal window and run it too (so there’s now two programs running simultaneously using the same code), does the second run affect the first running program as the first compiled output is replaced by the second compiled output?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

There are 3 scenarios possible :

  1. On Windows executable file will get locked for writing and removal while it is being executed so build will just fail.

  2. On Linux executable file is not necessary protected from modification or removal while it is being executed.

2.1. If file is deleted from FS and then a new file is created with the same name then old file content will still remain until already running executable exits while new executable will use new file. So old executable will continue to run normally while new one will be ready to work as well.

2.2. If file is opened for writing and overwritten with new content then already running executable will be using new machine code which is most likely incompatible with the existing program state and will lead to crashes.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading