NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: alexBishop on December 29, 2010, 06:16:01 AM

Title: multicore multiprocessor machine
Post by: alexBishop on December 29, 2010, 06:16:01 AM
Can anyone show me how to detect if a computer has more than one cpu, and also how to use the extra processors (run different code on each cpu by changing the eip register of each cpu). ???
Title: Re: multicore multiprocessor machine
Post by: Frank Kotler on December 29, 2010, 06:57:28 AM
Always embarrasing to google for something and find a link to me saying "Jeez, I don't know."! This is still what I don't know:

http://coding.derkeiler.com/Archive/Assembler/comp.lang.asm.x86/2007-07/msg00239.html

Note the typo! Should be "eax=0"!

This seems better...

http://software.intel.com/en-us/articles/multi-core-detect/

I have also seen reference to eax=80000008h...

I can't help ya with how to use 'em, since I've only got one... not 26! :)

Best,
Frank

Title: Re: multicore multiprocessor machine
Post by: Keith Kanios on December 29, 2010, 04:13:24 PM
Review this OSDev.org Forum Thread (http://forum.osdev.org/viewtopic.php?p=94211).
Title: Re: multicore multiprocessor machine
Post by: menemenetekel on December 30, 2010, 09:04:53 PM
Hi,

if you want to use multiple processors in parallel simply start parallel threads using mostly this functions:

extern      CreateThread
extern      CloseHandle
extern      ResumeThread
extern      SuspendThread
extern      SetThreadPriority
extern      GetCurrentThreadId
extern      WaitForMultipleObjects
...
All from kernel32.dll

Because those threads (by default - it's possible but not recommended to assign them to target CPUs manually) will be distributed to all available CPUs rsp. cores by OS controlled thread dispatcher(s) you need not to know the number of CPUs...
But if you want your program to know this number the simplest way would be to ask the environment variable NUMBER_OF_PROCESSORS

Cheers,
Mene