The way you are doing this is VERY complicated and probably in-efficient. Apple recommends that developers migrate away from threads to Grand Central Dispatch. This provides a very robust, efficient system to manage multi-threading. I does the work for you by optimizing the use of the cores in your machine without you having to do things like trying to figure out how many cores are available, in fact they advise you not to do this:
https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/ConcurrencyandApplicationDesign/ConcurrencyandApplicationDesign.html
OpenMP probably isn't up to date and or doesn't take advantage of this technology very well. GCD has the advantage of being available on any processor or OS version.
You should be able to run each of these processes in its own serial or more likely concurrent dispatch queue and let GCD execute them efficiently. Running each of these with its own copy of the app is probably much slower than it would be to launch each process with GCD due to overhead like context switching. You could write one source code file to launch these and be notified when they are done and it would be much easier for you than doing this with the terminal. You should at least read the Concurrency Programming Guide and see if it would make your life easier and speed up your app.
Topic:
App & System Services
SubTopic:
Core OS
Tags: