Consider an executable named makecookie
(plain old serial/non-parallelized program). I'd like to run two instances of it at the same time (by opening two terminals, for example), as follows:
First Terminal:
~/makecookie vanilla dataToRead.dat
Second Terminal:
cd ~
mkdir secondJar
ln -s ~/makecookie secondJar/
secondJar/makecookie chocolate dataToRead.dat
The second argument is a configuration string and the 3rd argument is a data file to open and read. The result will be output to stdout
on the terminal.
This causes the same executable to execute at the same time. Will there any issues with this? Why or why not?
To open another window of a program, simply launch it again. An easier way to do this is to press and hold the Shift key and click on the program's icon in the taskbar. If the program allows multiple windows, then another instance will open up without a hinge.
Open multiple instances of an app using Shift + Click First, open the application you want to run in multiple instances.
On the taskbar, select the Task view icon, then select New desktop. Open the apps you want to use on that desktop and then when you want to switch to a different desktop, select Task view again.
How do I stop multiple programs from running? On most Windows computers, you can access the Task Manager by pressing Ctrl+Shift+Esc, then clicking the Startup tab. Select any program in the list and click the Disable button if you don't want it to run on startup.
Running multiple instances of a same executable doesn't cause any issues. In the eyes of operating system they are two different processes. Each instance have their own page tables, file descriptors, stack, PID etc.., which are independent of all other instances.
But when you are accessing a same resource on different processes then you have to synchronize the resource access by using any of the lock strategies. For example two instances writing to a same file will result in clutters in the file where one instance could possibly write in the middle of an another instance's data.
Two instances reading from a same file won't be a problem, but when one writes and other reads the result will be messy. Note: Each instance will have their own read/write pointer where they are reading/writing independent of other instances.
As you are using the file dataToRead.dat
purely for reading you won't get any issues.
Overall there is no issue in running multiple instances if you have properly synchronized the resource access.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With