473,320 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

fork on multiple cpu server

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
4 2471
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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Benoit Dejean | last post by:
hello, i have a question about forking processes atm, i have some code which i want to rewrite os.system("cd ~ && exec " + cmd + " & disown") i want to remove this os.system call
2
by: Josh Denny | last post by:
I am trying to write a simple file transfer server in perl that will reside of both windows and linux platforms. Basically, it accepts a connection, forks a process, and then should close the...
4
by: marconi | last post by:
hallo there, Can anyone help me to look at my fork problems? I can't seem to work up the piping..the reason i need that for is because i need to make a counter global to client and...
27
by: steve | last post by:
I was given the following code, and asked what the possible outputs could be. We're learning about processes and forking. int value; int main(){ int pid, number = 1; value = 2; pid = fork();...
1
by: chad.vice | last post by:
I have a CGIC program that generates reporting output on-the-fly. At times this generation can take a long time, and session timeouts occur while users wait for the page results to be displayed. ...
5
by: JoeW | last post by:
Now before I go into detail I just want to say that this is purely for my own benefit and has no real world usage. I remember way back when the tool for *nix systems called forkbomb was created. I...
2
by: Rafael Giannetti Viotti | last post by:
Hi, I am working with the subprocess.py module in Python 2.4.4 and I am confused about it's functionality. It uses the standard pipe-fork-exec method to start a subprocess: # create pipes ...
1
by: Falcolas | last post by:
Hi all, This may be more of a Linux question, but it relates to how Python forks... Today, I implemented a pretty simple listener script using os.fork. The script runs fine, and performs as...
1
by: 3srt | last post by:
Hello, I created a simple 'server' script that will accept input from a cgi script. The server will handle multiple connections on the same port, also. In a nut shell, this 'server' script will...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.