By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

fork on multiple cpu server

P: n/a
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 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
sc*********@hotmail.com <sc*********@hotmail.comwrote:
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 ___ jt@toerring.de
\__________________________ http://toerring.de
Aug 9 '07 #2

P: n/a
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 '07 #3

P: n/a
In article <11**********************@g4g2000hsf.googlegroups. com>,
sc*********@hotmail.com <sc*********@hotmail.comwrote:
>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.
Aug 9 '07 #4

P: n/a
"sc*********@hotmail.com" <sc*********@hotmail.comwrites:
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-PO.../dp/0201633922
Aug 9 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.