From: Tony Johansson on
Hi!

I will be sure that I have understood this correctly.
Assume you have a computer with two kernels and I run two additional threads
that run the same method
can then these two threads be executing fysically the exact same instruction
at the exact same time.

As fas as I understand this I mean you would still use the mechanism of
pre-emptive multitasking between these two threads.

I mean that you do have two threads executing at the same time but you still
use the mechanism of pre-emptive multitasking between them so at any singe
moment in time only one of these two threads is really executing an
instaruction while the other is waiting to get cpu time to continue
executing.

//Tony


From: Rick Lones on
Tony Johansson wrote:
> Hi!
>
> I will be sure that I have understood this correctly.
> Assume you have a computer with two kernels and I run two additional threads
> that run the same method
> can then these two threads be executing fysically the exact same instruction
> at the exact same time.

Assuming you mean two CPU cores and not two kernels, then the answer is yes.
If you have two CPUs, then each is capable of independently running a given
instruction stream simultaneously with whatever the other one is doing. So in
principle they could be executing in lockstep different invocations of the same
instruction stream, although this would be highly unlikely. (If that's what you
really mean to ask here.)

> As fas as I understand this I mean you would still use the mechanism of
> pre-emptive multitasking between these two threads.

Yes, always.

> I mean that you do have two threads executing at the same time but you still
> use the mechanism of pre-emptive multitasking between them so at any singe
> moment in time only one of these two threads is really executing an
> instaruction while the other is waiting to get cpu time to continue
> executing.

Well, yes. But now you are back to talking as if there is only one CPU core.
With one CPU you get multi-tasking. With multiple CPUs you get concurrent
execution where EACH core is being muli-tasked by the operating system.

HTH,
-rick-
From: Arne Vajhøj on
On 10-05-2010 05:13, Tony Johansson wrote:
> I will be sure that I have understood this correctly.
> Assume you have a computer with two kernels and I run two additional threads
> that run the same method
> can then these two threads be executing fysically the exact same instruction
> at the exact same time.
>
> As fas as I understand this I mean you would still use the mechanism of
> pre-emptive multitasking between these two threads.
>
> I mean that you do have two threads executing at the same time but you still
> use the mechanism of pre-emptive multitasking between them so at any singe
> moment in time only one of these two threads is really executing an
> instaruction while the other is waiting to get cpu time to continue
> executing.

If you have N execution units (approx. equals to cores for
modern desktop CPU's), then N thread can execute in parallel
on their own execution unit.

Preemptive multitasking does not mean just one thread executing. It
means that threads get removed from the CPU by the OS.

Arne