Menu

THREADS

2016-07-24
2018-01-27
  • Lowell Boggs, Jr.

    Threads

    Brash is a multithreaded program that uses a command handler thread pool. The size of that pool is set at the beginning of execution and it cannot change. The default size is 20 threads.

    Uses of threads
    There are 3 basic uses of threads in brash:
    1. background jobs
    2. pipe members
    3. command line handling

    Command Line Handling

    When brash is reading from the console, every command you type in gets executed in a background thread. Thee command handler threads waits until completion of the secondary thread that gets created in order to execute this command just entered.

    This not true of scripts invoked using a command of the form "brash.exe -script filename". The entire script execution can occur in a single thread -- unless of course, pipes are involved or background jobs are created.

    If you invoke functions or scripts from a console, a single thread handles the entirety of execution of the function or script.

    Pipe Members

    A pipe is a command that looks like this:

    Command1 | Command2 | Command3 ...
    

    In this example, 4 threads are involved: Each command gets its own, the pipe gets one on top of that.

    Background Jobs

    Background jobs are created when you complete a command by using the & character. That character replaces a ; as a command terminator and means to launch the job in a separate thread which shares access to stdin, stdout, and stderr. Generally, you want to redirect these files as part of a command invocation -- though occaisionally not. Here's an example of creating a background job then listing the background jobs to see it running:

    Command <inputFile >outputFile 2>&1  &
    jobs
    

    The output of the above command will be the job id of the command line launched into the background with the & character.

    Increasing the number of threads

    This page discusses how to increase the numbeer of threads:

    https://sourceforge.net/p/winbrash/discussion/examples/thread/bd3063c2/

     

    Last edit: Lowell Boggs, Jr. 2018-04-24
  • Lowell Boggs, Jr.

    Actually, the default number of threads was increased to 40.

     
  • Lowell Boggs, Jr.

    You can increase the number of running threads either from the command line or from inside a running script. See https://sourceforge.net/p/winbrash/discussion/examples/thread/bd3063c2/

     

Anonymous
Anonymous

Add attachments
Cancel