LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-08-2008, 09:07 AM   #1
exceed1
Member
 
Registered: Mar 2008
Location: oslo
Distribution: debian,redhat
Posts: 199

Rep: Reputation: 31
Can two processes run at the same time on a dual-core processor?


Hi

Im wondering if two processes can run at the same time when running a dual-core processor. Im well aware that normally only one process can run at a time usually, but i dont know how this is working when youre running a dual-core processor.
 
Old 04-08-2008, 09:40 AM   #2
camorri
LQ 5k Club
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 15.0, current, slackware-arm-currnet
Posts: 6,215

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
Yes they can. Whether they do or not depends on the OS you are using. Linux can use both at the same time. There would be no point in having more than one id the OS couldn't use more than one. A kernel with SMP support indicates the OS is capable of using more than one processor.

Here is what uname shows on my dual core system.

Quote:
Linux duelie 2.6.22.18-desktop586-1mdv #1 SMP Mon Feb 11 12:21:41 EST 2008 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 5200+ GNU/Linux
 
Old 04-08-2008, 01:33 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by exceed1 View Post
Hi

Im wondering if two processes can run at the same time when running a dual-core processor. Im well aware that normally only one process can run at a time usually, but i dont know how this is working when youre running a dual-core processor.
That depends on how you define "run at a time". If you mean
"completely dedicated to the one task", then no, you'd need
three CPUs at least, otherwise at least one of the cores will
be running the kernel as well. If that's what you need, use
DOS ;} and two stand-alone machines.
If you mean run in parallel with time-slices a human won't
notice - by all means - Linux can run many processes "at the
same time" on a single CPU.


Cheers,
Tink
 
Old 04-08-2008, 01:54 PM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by Tinkster View Post
That depends on how you define "run at a time".
I don't see anything in the original question that requires all that qualification.

Quote:
Originally Posted by exceed1 View Post
Im wondering if two processes can run at the same time when running a dual-core processor.
The answer is simple: Yes

"can" would not be interpreted as meaning "will 100% of the time".

Maybe one of the processes has multiple threads and sometimes two threads of one process will be running at the same time instead of one thread each of two processes. Of course, interrupts must still be serviced and there is other kernel CPU time that you might or might not consider to be part of the CPU time of one of those processes. None of that changes the "yes" to the question asked.

Quote:
Originally Posted by Tinkster View Post
If you mean run in parallel with time-slices a human won't
notice - by all means - Linux can run many processes "at the
same time" on a single CPU.
It sounds like you're saying "at the same time" can't mean any more for dual core than it means for single CPU. That would not be correct. Linux uses time-slices to run multiple processes "at the same time" where "at the same time" does not mean what the OP clearly meant. But with dual core it can and often does run two processes "at the same time" where "at the same time" does mean really at the same time as the OP meant.

Last edited by johnsfine; 04-08-2008 at 02:02 PM.
 
Old 04-08-2008, 02:05 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by johnsfine View Post
I don't see anything in the original question that requires all that qualification.
I disagree. When someone asks a simple question, we can't know all the underlying assumptions or the context.

The normal single-CPU machine--by definition--only does one thing at a time. But it does keep track of multiple processes--allowing each one to take it's turn.
2 CPUs can indeed do two things at the same time--thus (theoretically) increasing the speed.

From another angle: A modern computer can run many processes concurrently---but not because it has more than one processor.
 
Old 04-08-2008, 02:07 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by johnsfine View Post
I don't see anything in the original question that requires all that qualification.
Do you always give a "simple answer", or one that
may be close to correct?


Quote:
Originally Posted by johnsfine View Post
It sounds like you're saying "at the same time" can't mean any more for dual core than it means for single CPU. That would not be correct. Linux uses time-slices to run multiple processes "at the same time" where "at the same time" does not mean what the OP clearly meant. But with dual core it can and often does run two processes "at the same time" where "at the same time" does mean really at the same time as the OP meant.
Again - it depends on how it's defined. Whether the OP was
specific on that or not. And in the strictest possible inter-
pretation it's a NO, because there's always kernel code in
the mix.


Cheers,
Tink
 
Old 04-08-2008, 03:27 PM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by Tinkster View Post
Do you always give a simple answer", or one that may be close to correct?
Generally not. (You can look at my many answers given on remote control questions at RemoteCentral). I'm usually the first to suggest that a question might not mean what it seems to mean, or even that the questioner is not asking the question he should be asking.

But this time, we all know exactly what the OP meant. We don't need to invent possible alternate meanings to justify a more confusing answer.

Quote:
And in the strictest possible inter-
pretation it's a NO
Nonsense. The strictest possible interpretation of "can run at the same time" still means "can run at the same time" so the answer is Yes.

There may be other ways of interpreting "can run at the same time" to inject "always" somewhere in there. But that would not be a strict interpretation of the original phrase.

I have a dual core CPU. I use a software build system that runs compiles in two processes "at the same time". During most of the time those compiles are "running" there are two processes really running really at the same time (really), not just seeming to run at the same time as would be the case with a single core CPU. When something does happen a lot, it is pretty distorted to respond to "can it happen" with some interpretation that makes the answer "no".

Last edited by johnsfine; 04-08-2008 at 03:28 PM.
 
Old 04-08-2008, 03:48 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by johnsfine View Post
But this time, we all know exactly what the OP meant. We don't need to invent possible alternate meanings to justify a more confusing answer.
Not to all, apparently. There's at least two people who don't
think that it's quite clear what the OP meant.

Quote:
Originally Posted by johnsfine View Post
Nonsense. The strictest possible interpretation of "can run at the same time" still means "can run at the same time" so the answer is Yes.

There may be other ways of interpreting "can run at the same time" to inject "always" somewhere in there. But that would not be a strict interpretation of the original phrase.

I have a dual core CPU. I use a software build system that runs compiles in two processes "at the same time". During most of the time those compiles are "running" there are two processes really running really at the same time (really), not just seeming to run at the same time as would be the case with a single core CPU. When something does happen a lot, it is pretty distorted to respond to "can it happen" with some interpretation that makes the answer "no".
You obviously haven't read my first response ... oh well.
Quote:
If you mean run in parallel with time-slices a human won't
notice - by all means - Linux can run many processes "at the
same time" on a single CPU.
Figures.



Cheers,
Tink
 
Old 04-08-2008, 05:38 PM   #9
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by Tinkster View Post
You obviously haven't read my first response
I certainly read it. I'm sure I understand what the OP meant. But that doesn't mean I'm sure I understand what you meant. I expect I don't understand what you mean. I really can't tell whether you are wrong about the underlying facts or just wrong about what the original question might have meant (sorry, but those are the only two possibilities I can still see).

Quote:
Originally Posted by Tinkster View Post
If you mean "completely dedicated to the one task"
I'm quite sure the OP did not mean that.

Quote:
Originally Posted by Tinkster View Post
If you mean run in parallel with time-slices a human won't notice
I'm equally sure the OP did not mean that.

If you mean those are the plausible ways to look at the question, then maybe you don't even agree with me about the answer to the question I think the OP asked. Obviously you don't agree regarding what question was asked. I expect you would at least understand what question I think he asked and you seem to be going to some effort to avoid answering that and to throw confusion on top of camorri's original answer to that.

When my dual core CPU is running two processes at once, those are not just "at the same time" within some chunk of time too small for me to notice (as would happen with a single core CPU). They are not just at the same time within a single microsecond. They are not just at the same time within a single nanosecond. They are not even just at the same time within a single CPU clock (less than a nanosecond). They are really at the same time, even as individual electrons move seperately in the two cores to charge some gates whose switchings are tiny parts of the execution of two unrelated machine instructions, one in each core.

I also don't even know whether you mean to be answering the question of the original post "if two processes can run at the same time when running a dual-core processor" or whether you are "answering" the background statement he put in for contrast "normally only one process can run at a time". That statement would be subject to all manner of reinterpretation and disagreement (such as you have done) if it weren't present just as contrast to the real question.

I'm quite sure that contrast statement is there just to make extra sure that the real question can't be misinterpreted in ways such as:

Quote:
run in parallel with time-slices a human won't notice

Last edited by johnsfine; 04-08-2008 at 05:43 PM.
 
Old 04-08-2008, 06:17 PM   #10
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
I'm not technically advanced enough to address the issue at the level entered into above, but here's an experiment you can replicate, and I think it addresses the OP's question.

In the Grip setup is a question of how many processors you want Grip to use. Select one (1), give it a CD, and it'll rip all the files to .wav, then convert each .wav file to .mp3, .ogg, or whatever. Tell Grip you want it to use two (2) processors, and it'll use one to rip the files to .wav, and the 2nd processor to concurrently convert the .wav files to .mp3s. Using two processors, the entire process takes only half as long.

I only have 2 processors, but I am curious to know how it would deal with 3 or 4.
 
Old 04-08-2008, 06:58 PM   #11
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by rickh View Post
here's an experiment you can replicate, and I think it addresses the OP's question.
Sorry, but I think it doesn't.

Long ago, I made a lot of use of a program that alternated small chunks of CPU usage with small chunks of disk I/O. The mix turned out to be about 50/50. There were no dual core CPUs. I didn't have any kind of multi-processor system. But I made it run two copies of that process in parallel and the total time was reduced to barely over half the original time.

In such a situation, the two processes tend to fall into an optimal syncronization in which one is using CPU time while the other is waiting for disk I/O and vice versa. So running two copies in parallel is much faster than running just one, even with just one CPU core.

Your example mixes CPU usage and disk I/O in a similar way. I expect the mix isn't near 50/50. I expect a modern OS's file caching will gain much of the overlap even for a single process that I needed two processes to achieve. So if you ran two processes in parallel with a single core CPU I wouldn't expect the total time to be near as low as half of the single process time. But I don't know the values of any of those unknowns. So if on some unknown system, you found that two processes in parallel do the job twice as fast as one process, I wouldn't jump to the conclusion that two cores are at work. That would be suggested, but not proven. It could just be an unusually good example of CPU vs. I/O overlap of two processes.
 
Old 04-08-2008, 11:19 PM   #12
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by johnsfine View Post
I'm sure I understand what the OP meant.
How about we give the OP a chance to clarify? It's mote
for us to argue about what either of us thinks he's asking.

Quote:
They are not just at the same time within a single nanosecond. They are not even just at the same time within a single CPU clock (less than a nanosecond). They are really at the same time,
You're wrong. While they may both be in the kernels scheduler
queue as high priority tasks one processes execution may be
stopped for the kernels scheduling activities for several jiffies
on one CPU while the other is stopped for a few jiffies for IO
tasks on the other ...


I'm fairly certain (probably about as certain as you) that
I got the right end of the stick, but I can't be bothered
to expend any more time on this logorrhea ...



Cheers,
Tink

Last edited by Tinkster; 04-08-2008 at 11:24 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel Panic on Intel Core 2 Duo E6700 Dual Core Processor nwongrat Linux - Hardware 2 01-08-2008 10:13 PM
Run all OS processes on one core in multicore processor tryon16 Linux - Kernel 6 10-02-2007 05:13 PM
With Dual core, can Winxp and Linux run at the same time? jang Linux - General 20 07-17-2006 10:15 PM
Dual processor vs. Dual core cs. single on home machine fincher69 Linux - Hardware 3 03-04-2005 12:37 PM
dual processor system=more running processes? plisken Linux - Hardware 0 12-09-2004 03:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration