Author Topic: multicore multiprocessor machine  (Read 13974 times)

Offline alexBishop

  • Jr. Member
  • *
  • Posts: 10
multicore multiprocessor machine
« 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). ???

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: multicore multiprocessor machine
« Reply #1 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:

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

This seems better...

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! :)


Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: multicore multiprocessor machine
« Reply #2 on: December 29, 2010, 04:13:24 PM »

Offline menemenetekel

  • Jr. Member
  • *
  • Posts: 7
  • Country: de
Re: multicore multiprocessor machine
« Reply #3 on: December 30, 2010, 09:04:53 PM »

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