nsastickers.blogg.se

Windows parallel processing
Windows parallel processing




off setlocal enableDelayedExpansion :: Display the output of each process if the /O option is used :: else ignore the output of each process if /i "%~1" equ "/O" ( set "lockHandle=1" set "showOutput=1" ) else ( set "lockHandle=1^>nul 9" set "showOutput=" ) :: The list of commands could come from anywhere such as another file :: or the output of another command. I've tested this on XP, Vista, and Windows 7. My demo sets the process limit to 4, and simply runs a series of PING commands of varying length. If started with the /O option as the 1st parameter, then it displays the output of each process, without interleaving. The redirection will fail if the process is still active, succeed if it has terminated.īy default, the script ignores the output of each process. The master script can test if the process is still active by attempting to redirect to the same lock file.

windows parallel processing

It doesn't matter how the process terminates (normal exit, crash, killed process), the lock will be released as soon as it does. The process will maintain an exclusive lock on the file until it terminates. The trick to make this work is to START each command through a CMD process that redirects either stdout or an undefined handle to a lock file. It even has a mechanism built in to distribute the processes to specific CPUs or remote machines via PSEXEC, but I haven't tested that feature. Here is a native batch solution that reliably runs a list of commands in parallel, never launching more than n processes at a time. Edit - I modified the script to optionally display the output of each process






Windows parallel processing