Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to create a batch-file that calls 2 other batch-files in different threads. Each thread shall be performed on another core of the processor.
How to realize this?

Thanks in advance for any help!
Posted

If it were OK for you to use PowerShell multithreading would indeed be an option. I found an example here: http://blog.isaacblum.com/2010/01/22/powershell-multithreading-omg/[^]. Googling +PowerShell +Multithreading yields 111K results. I'm sure you'll find more examples as you come along.

Cheers!
 
Share this answer
 
Comments
Apfelmuuus 9-Mar-11 10:34am    
Thank you I guess I found something usefull:
powershell-setting-processor
TweakBird 9-Mar-11 14:33pm    
Good Link Have 5+
Sergey Alexandrovich Kryukov 9-Mar-11 17:52pm    
Can be a valid option, my 5. However, I feel the applicability of batch or script are almost exhausted for the OP's requirements, so my alternative Answer may make sense.
--SA
Start multiple instances of the same console app. Each running application under Windows exists within its own thread.

Beyond that, you shouldn't have to mess with assigning core affinity because .Net apps combined with Windows 7 will make the most efficient use of your system's architecture pretty much on its own.
 
Share this answer
 
v3
Comments
Manfred Rudolf Bihy 9-Mar-11 9:51am    
I'm not sure how you came to the console application part. OP only mentioned batch programming in his tagging of the question as well as in the question itself. It's still a viable option to follow this though as I believe hearing something about an exe wrapper for cmd and batch files a while back.

Take my 5!
#realJSOP 9-Mar-11 10:07am    
Well, given the implied requirements that he wants multiple threads in a batch file, it doesn't make sense to run two GUI apps from a batch file, now does it? :)
Apfelmuuus 9-Mar-11 10:32am    
Exact! It wouldn't make sense, however, I want to run 2 batch files no GUI apps.
Furthermore I'm working with Windows XP and I do not know whether it assigns core affinity on its own or not. Any suggestions?
Manfred Rudolf Bihy 9-Mar-11 11:25am    
Batch processing files don't have to run any applications at all as long as the stuff they're doing can be done via built in commands.
Sergey Alexandrovich Kryukov 9-Mar-11 17:53pm    
Basically, you're right, (my 5) only I feel the applicability of batch or script are almost exhausted for the OP's requirements, so my alternative Answer may make sense.
--SA
I suggest with your requirements you should eliminate batch files. This is not adequate technique. The problem is not even starting several processes, the problem is having no access to the process handles when they are started. Programming using CreateProcessEx (Windows API) or Process.Create (.NET) solves this problem completely. You can use some data objects to store list/sequence of applications or any meta-data you may possibly need. (Embedding the code in yours is also sometimes possible, but it's a matter of a separate thread of discussion.)

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900