fork on multiple cpu server

Discussion in 'C Programming' started by sc_wizard29@hotmail.com, Aug 9, 2007.

  1. Guest

    Hi everyone,

    One of my collegue at work said that on a 4 CPU server, it's better to
    write a program that forks 4 "sub-processes" instead of writing a
    single process program (ie : a program that doesn't call fork())

    I guess the theory behind this is that each one of the 4 sub-processes
    can be processed by a separate CPU, which means that in a ideal
    scenario, 4 instructions can be processed "at the same time".

    What is your opinion on this ?
     
    , Aug 9, 2007
    #1
    1. Advertising

  2. <> wrote:
    > One of my collegue at work said that on a 4 CPU server, it's better to
    > write a program that forks 4 "sub-processes" instead of writing a
    > single process program (ie : a program that doesn't call fork())


    > I guess the theory behind this is that each one of the 4 sub-processes
    > can be processed by a separate CPU, which means that in a ideal
    > scenario, 4 instructions can be processed "at the same time".


    While your collegue might be right, this is the wrong place for
    a discussion since it doesn't got anyhing to do with C, which is
    the topic of this group (and the C standard doesn't even consider
    that there could be more than one program running at a time). Per-
    haps you should ask in a UNIX group (e.g. comp.unix.programmer)
    since fork() historically came form UNIX (if I am not completely
    mistaken) or in comp.programming, where all kinds of questions
    related to programming get discussed.

    Regards, Jens
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
     
    Jens Thoms Toerring, Aug 9, 2007
    #2
    1. Advertising

  3. In article <>,
    <> wrote:

    >One of my collegue at work said that on a 4 CPU server, it's better to
    >write a program that forks 4 "sub-processes" instead of writing a
    >single process program (ie : a program that doesn't call fork())
    >
    >I guess the theory behind this is that each one of the 4 sub-processes
    >can be processed by a separate CPU, which means that in a ideal
    >scenario, 4 instructions can be processed "at the same time".


    This is reasonable if your program can be decomposed into parts that
    can be run simultaneously, without much need to communicate. If they
    need to share data, you may find it easier to use multiple threads
    inside a single program. How you do this depends on your system;
    C itself does not include any thread mechanism.

    Bear in mind that other people using the server may be annoyed at your
    making full use of it...

    -- Richard

    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
     
    Richard Tobin, Aug 9, 2007
    #3
  4. Guest

    Well, I guess you're right but since it was in the context of a C
    program... well, never mind : thanks for answering !
     
    , Aug 9, 2007
    #4
  5. Richard Guest

    "" <> writes:

    > Hi everyone,
    >
    > One of my collegue at work said that on a 4 CPU server, it's better to
    > write a program that forks 4 "sub-processes" instead of writing a
    > single process program (ie : a program that doesn't call fork())
    >
    > I guess the theory behind this is that each one of the 4 sub-processes
    > can be processed by a separate CPU, which means that in a ideal
    > scenario, 4 instructions can be processed "at the same time".
    >
    > What is your opinion on this ?
    >


    Look up Amdahl's law.

    http://en.wikipedia.org/wiki/Amdahl's_law

    It is discussed in this great book:

    http://www.amazon.com/Programming-POSIX-Threads-David-Butenhof/dp/0201633922
     
    Richard, Aug 9, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. xchris
    Replies:
    5
    Views:
    4,144
  2. Eric Snow

    os.fork and pty.fork

    Eric Snow, Jan 8, 2009, in forum: Python
    Replies:
    0
    Views:
    590
    Eric Snow
    Jan 8, 2009
  3. pavunkumar

    How , system cpu and user cpu times calculates

    pavunkumar, Feb 27, 2009, in forum: C Programming
    Replies:
    1
    Views:
    369
  4. Eric Wong
    Replies:
    0
    Views:
    106
    Eric Wong
    Dec 10, 2009
  5. Ganchrow Harris Peck

    Bizarre SvTYPE after fork on W2K Server

    Ganchrow Harris Peck, Sep 8, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    110
    Ganchrow Harris Peck
    Sep 8, 2003
Loading...

Share This Page