none
Q. about allocating processes in .Net RRS feed

  • Question

  • Hello all,

    I'm writing some program which should perform calculations concurrently according to inputs which reach the system all the time. I'm considering 2 approaches to allocate "calculation" processes:
    1. Allocating processes in the system initialization, insert the ids to Processes table, and each time I want to perform calculation, I will check in the table which process is free. 
    The questions: can I be sure that those processes are only for my use and that the operating system doesn't use them?
    2. Not allocating processes in advance. Each time when calculation should be done ask the operating system for free process.

    I need to know the following inputs from a "calculation"  process:
    1. When calculation is finished and also if it succeeded or failed
    2. If a processes has failed I need to assign the calculation to another process

    I hope my post is not too long.

    Thanks in advance. Any help would be appreciated.

    maya
    Tuesday, March 9, 2010 6:52 AM

Answers

  • By "process" do you mean a windows process or application? If so, that seems like a difficult approach to do concurrent work on a PC. Why not keep all calculation in a single process and utilize multithreading to do the work in parallell, much like a server would handle incoming requests.
    Using separate processes as compared to multithreading in a single app won't make much difference when it comes to performance. The system has to divide cpu time between all processes threads anyway, regardless of having one process with 10 threads, or 10 processes with 1 thread each.

    /Calle 
    - Still confused, but on a higher level -
    • Marked as answer by eryang Monday, March 15, 2010 1:44 AM
    Tuesday, March 9, 2010 12:52 PM
  • You might want to look at Thread pool pattern and ThreadPool class in .NET.
    Or you might use Parallel Extensions in .NET to paralelize your code.

    -Karel
    • Marked as answer by eryang Monday, March 15, 2010 1:44 AM
    Tuesday, March 9, 2010 9:03 PM
    Moderator

All replies

  • By "process" do you mean a windows process or application? If so, that seems like a difficult approach to do concurrent work on a PC. Why not keep all calculation in a single process and utilize multithreading to do the work in parallell, much like a server would handle incoming requests.
    Using separate processes as compared to multithreading in a single app won't make much difference when it comes to performance. The system has to divide cpu time between all processes threads anyway, regardless of having one process with 10 threads, or 10 processes with 1 thread each.

    /Calle 
    - Still confused, but on a higher level -
    • Marked as answer by eryang Monday, March 15, 2010 1:44 AM
    Tuesday, March 9, 2010 12:52 PM
  • You might want to look at Thread pool pattern and ThreadPool class in .NET.
    Or you might use Parallel Extensions in .NET to paralelize your code.

    -Karel
    • Marked as answer by eryang Monday, March 15, 2010 1:44 AM
    Tuesday, March 9, 2010 9:03 PM
    Moderator