1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Threads

Discussion in 'Suggestions' started by Roedy, Feb 29, 2012.

  1. Roedy

    Joined:
    Jun 8, 2008
    Messages:
    120
    Likes Received:
    2
    I have 6 cpu cores, but very few utilities will use more than one of them at a time. I thought I might write some bat files that split up and ran in parallel for a while then rejoined. I might use it to zip different directories, validate HTML on different sets of files etc, anything heavily CPU eating.

    I am not aware of any TCC tools for doing this. You need a way to launch a btm file to run independently, and and you need something that will wait until N precesses check in.
     
  2. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    697
    Likes Received:
    8
    Take a look at the DETACH command, and the _DETACHPID variable.

    I use these to run several batch files at once, writing results to files. Using _DETACHPID I can tell when the batch file has ended, and process the resulting files that were generated from my batch files.

    While this is not going to use 6 cpu cores, nor is it actual threading, it accomplishes the same thing for my needs.

    Joe
     
  3. haskell

    Joined:
    Jun 6, 2008
    Messages:
    15
    Likes Received:
    0
    Doesn't "START /AFFINITY=n" work?
     
  4. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    697
    Likes Received:
    8
    Code:
    ::+-------------------------------------------------------------------+
    ::| TEST.BTM - Show how to run several batch files at the same time, |
    ::| and determine when they have all finished. |
    ::| |
    ::| February 29, 2012 - Joe Caverly |
    ::|-------------------------------------------------------------------+
    @setlocal
    @echo off
    ::
    :: Create five batch files
    ::
    echo delay 7 > proc1.btm
    echo delay 2 > proc2.btm
    echo delay 3 > proc3.btm
    echo delay 4 > proc4.btm
    echo delay 5 > proc5.btm
    ::
    :: Track the processes with a counter
    ::
    set procs_running=5
    ::
    :: Start each batch file in detached mode
    ::
    detach proc1.btm
    set proc1=%_detachpid
    detach proc2.btm
    set proc2=%_detachpid
    detach proc3.btm
    set proc3=%_detachpid
    detach proc4.btm
    set proc4=%_detachpid
    detach proc5.btm
    set proc5=%_detachpid
    ::
    :: Check the progress of the detached batch files
    ::
    do until %procs_running lt 1
    iff defined proc1 then
    iff %@isproc[%proc1] eq 0 then
    echo Process 1 finished.
    unset proc1
    set procs_running=%@dec[%procs_running]
    endiff
    endiff
     
    iff defined proc2 then
    iff %@isproc[%proc2] eq 0 then
    echo Process 2 finished.
    unset proc2
    set procs_running=%@dec[%procs_running]
    endiff
    endiff
     
    iff defined proc3 then
    iff %@isproc[%proc3] eq 0 then
    echo Process 3 finished.
    unset proc3
    set procs_running=%@dec[%procs_running]
    endiff
    endiff
     
    iff defined proc4 then
    iff %@isproc[%proc4] eq 0 then
    echo Process 4 finished.
    unset proc4
    set procs_running=%@dec[%procs_running]
    endiff
    endiff
     
    iff defined proc5 then
    iff %@isproc[%proc5] eq 0 then
    echo Process 5 finished.
    unset proc5
    set procs_running=%@dec[%procs_running]
    endiff
    endiff
     
    enddo
     
    ::
    :: All detached batch files have finished
    ::
    ::
    :: Remove the batch files created earlier
    ::
    if exist proc1.btm del proc1.btm > nul
    if exist proc2.btm del proc2.btm > nul
    if exist proc3.btm del proc3.btm > nul
    if exist proc4.btm del proc4.btm > nul
    if exist proc5.btm del proc5.btm > nul
    endlocal
     
  5. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,201
    Likes Received:
    11
    Or you can use my EVENTUTILS plugin.

    ftp://ftp.jpsoft.com/plugins/event11.zip

    -Scott
     
  6. Roedy

    Joined:
    Jun 8, 2008
    Messages:
    120
    Likes Received:
    2
    Good stuff. Thanks.
     
  7. Roedy

    Joined:
    Jun 8, 2008
    Messages:
    120
    Likes Received:
    2
    There no notes on iinstalling. Do you just put the appropriate DLL in the takecommand directory? You don't have to do anything to configure tcc to go looking for it?
     
  8. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    No, not in the TCMD installation directory, but its subdirectory named PLUGINS for automatic activation on TCC start. Alternately, anywhere else, and dynamically activate or deactivate with the appropriate options of the PLUGIN command, as documented by HELP -> PLUGIN.
     

Share This Page