0

I have to run around 2000 commands, basically they are PC-Lint (static code analysis tool for C++) commands (lint-nt.exe). PC-lint executable when it runs takes up huge CPU time and occupies good amount of memory. This is the reason, I can't run all 2000 commands at once!

I am looking for a commandline tool which can help me assess the CPU and memory conditions and schedules maximum possible commands to run in parallel.

The question has nothing to do with PC-Lint. You may take any other commandline utility which acquires good amount of system resources.

Right now, I am just running a command and wait for completion. but I know I can run these commands in parallel.

start /wait cmd /c "<COMMAND>"
start /wait cmd /c "<COMMAND>"
start /wait cmd /c "<COMMAND>"
...

Any ideas? You may also suggest PowerShell based solution.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
user1
  • 4,031
  • 8
  • 37
  • 66
  • I don't think you can do it as a DOS command, you can look however at Powershell, it gives you access to Windows resources – JanR Mar 22 '16 at 05:12
  • Fine, pls suggest how to achieve this with powershell. I am editing the questions. I will add powershell tag. – user1 Mar 22 '16 at 05:12
  • There are no "DOS commands" in Windows (except you are still working with Windows 3.x, 95, 98, ME); "DOS" is an OS from the 1980s; there is the command prompt `cmd` since Windows NT... Anyway, you could use `wmic CPU LIST` and check the information provided; then you can extract performance-specific information like `wmic CPU GET LoadPercentage` for instance and parse its output with a `for /F` command... – aschipfl Mar 22 '16 at 09:39
  • If you are prepared to install `cygwin`, you could harness the power of all your CPU cores with `GNU Parallel`. – Mark Setchell Mar 22 '16 at 09:55
  • 1
    Search for workflow with foreach parallel, jobs or runspaces in Powershell. It has been answered multiple times before. :-) – Frode F. Mar 22 '16 at 11:04
  • Use `start "" cmd /c ""` instead of `start /wait cmd /c ""` to run these commands in parallel. Moreover, [`start` command](http://ss64.com/nt/start.html) allows that started process would be restricted to running only on chosen processor(s), see `/AFFINITY` parameter. – JosefZ Mar 22 '16 at 11:29
  • 1
    Have a look at http://stackoverflow.com/a/11715437/1012053. That pure batch code does not automatically adjust the number of parallel processes, but it allows you to specify a max process count, and then lets those *n* processes work through a queue of jobs, such that all processes remain busy until the queue is exhausted. I think it could work well for you. – dbenham Mar 22 '16 at 16:42
  • @dbenham Thank you for the link. That's exactly I was looking for.. – user1 Mar 23 '16 at 03:06

0 Answers0