so how does instruction for multi cpu computers look like ??? do they specify which processor instruction is for ?? How does it work on dual mainboard PC ??
Posted on 2005-02-16 11:38:06 by AceEmbler
windows has threads, each thread will run on the specified processor, so if you have 2 cpus, you can have 1 thread for cpu 1 and 1 thread for cpu 2. each run independantly, like normal tthreading would on a single cpu, so its your job to have a mechinizm to communicate between them.
Posted on 2005-02-16 13:37:11 by Qages
The instructions used for multi-CPU programming are the same used for single-CPU programming (although you might need the "lock" prefix, and finally find a use for cmpxchg8b et cetera).

I'm not familiar with the actualy CPU scheduling logic, but look up "APIC" - you need to do some I/O port programming to enable the CPUs beyond the first one.
Posted on 2005-02-16 14:14:28 by f0dder
Just use SetThreadAffinityMask() on windows to specify which cpu it to run on.
Posted on 2005-02-16 22:23:40 by Qages
Just use SetThreadAffinityMask() on windows to specify which cpu it to run on.



Problem is that i have to design multi CPU computer for my studies.
Posted on 2005-02-17 04:11:09 by AceEmbler
PCs tend to use a simple method where by you label your processors 1 to n, and processor 1 is your "master" processor. It will run the kernel, and the kernel tells other processes (and threads) where to run.

Things like SetThreadAffinityMask tell the kernel it would be best if you run these threads on the same physical processor (they communicate a lot, so it's faster to comunicate on the same processor). This of course scales to clusters, where processors on the same cluster communicate at a higher speed than with those outside their cluster.

The other design of multi-processor systems is vector processing, which is what modern super-computers tend to use. This then relies on algorithm design to make use of all processors simultainiously. These designs tend to be much more costly, as they are much more IO intensive (it is the IO speed which makes them super, more-so than the plain processing grunt really).

Mirno
Posted on 2005-02-17 04:52:02 by Mirno
PCs tend to use a simple method where by you label your processors 1 to n, and processor 1 is your "master" processor. It will run the kernel, and the kernel tells other processes (and threads) where to run.
Mirno


how does it tell them ?? Is it using interrupts, like I/O devices ??
Posted on 2005-02-17 17:44:26 by AceEmbler
Just use SetThreadAffinityMask() on windows to specify which cpu it to run on.



Problem is that i have to design multi CPU computer for my studies.


actually, no if you use this and have only 1 cpu, the os is forced to run it on the only cpu that is there. if you specify the 2nd cpu , you are telling windows that you prefer that this thread run on the 2nd cpu, if there is one.
Posted on 2005-02-17 22:23:27 by Qages
i'm asking how OS is chosing cpu instruction will come to (special instruction or IRQ) ???
Posted on 2005-02-18 05:30:10 by AceEmbler
i'm asking how OS is chosing cpu instruction will come to (special instruction or IRQ) ???


like i said, with threading, you can choose which cpu the thread runs on, any instructions you execute will run on the cpu u specified.
Posted on 2005-02-18 13:30:37 by Qages
i'm asking how OS is chosing cpu instruction will come to (special instruction or IRQ) ???


like i said, with threading, you can choose which cpu the thread runs on, any instructions you execute will run on the cpu u specified.



Imagine that i have to write OS for multi CPU computer. How can i specify piece of code that will be run on second CPU ??
Posted on 2005-02-18 16:42:32 by AceEmbler
You will need to send a command through your chosen inter-processor protocol. The inter-processor hardware can be shared storage (RAM, disk, or other kinds) or a communication channel (serial, parallel, Ethernet, custom, etc.) The command (or message) can be of any design - defined by others, or by you. The destination processor must have code or hardware to interpret that command (and any other commands).
Posted on 2005-02-18 21:30:52 by tenkey
if you want to write an os for a multi cpu system. you need to use The Advanced Programmable Interrupt Controller (APIC). through this, you can write an interupt table for each of the cpus. throuhg your boot strap cpu, fhr first one, you can call the interupt and the code and the specified memory address will execute on the specified cpu. for a better read and understanding, read http://www.nondot.org/sabre/os/files/Processors/IntelMultiProcessorSpecv1.4.pdf
Posted on 2005-02-18 22:25:27 by Qages
There are generally two APICs. An I/O APIC and a Local APIC. You want the local APIC. It has memory mapped registers that map near the top of the 4GB range. So you'll have to be in protected mode ( or big real mode ) with your main processor to send APIC commands. The main processor is called BSP ( boot strap processor). All other processors are called AP processors ( application processors). You can specify how commands are sent. For example you can send a command from the BSP's local APIC telling all processors except itself to do something. For example you can tell all the APs to jump to a certain address. One of the commands you can send will tell all the APs to jump to a certain real mode segment. After you have them all executing that code then you can put them into protected mode.

If I remember right ( and I might be having a brain fart), you have to send a Startup IPI command to all the AP processors to wake them up first before you can send them commands. You would again use the command to broadcast to all processors except the BSP. That will make all the APs wake up.
Posted on 2005-02-18 22:37:06 by mark_larson
thank you all.
Posted on 2005-02-19 04:02:40 by AceEmbler