Processzorok logikai es fizikai szama x86 architekturan

Sziasztok,

A cegnel adodott egy kis problema a licensz modulban, ami rosszul szamolja ki egy gepen a processzorok szamat. Egy kicsit beleastam magam, hogy lehet a cpuid utasitassal infot lekerni egy processzorrol, de sajnos keves vagyok a megoldashoz.

mov eax,1
cpuid
--> eax[23:16] Maximum number of addressable IDs for logical processors in this physical package
--> edx[28] HTT-multithreading
ezekbol sajnos nem tudom kivadaszni az infot, ami nekem kell.

Mivel az elkeszult kod platformfuggetlen kell legyen, nem tudok a linux kornyezetben mar adott /proc/cpuinfo-ra hagyatkozni. Mindenkepp egy assembly-ben megirt fugvenyre van szuksegem, ami visszaadja, hogy hany processzor, mag illetve logikai processzor van a gepben.

Varom a tippeket!

Udv,
Gabor

Hozzászólások

Platform fuggetlenseg mit jelent most szamodra ?
32 bit x86 Linux/Windows + gcc?

olyan x86_32 vagy x86_64 architekturan futo operacios rendszer fuggetlen (nem akarok valami winapi-ra vagy /proc/cpuinfo file-ra hagyatkozni) megoldasra van szuksegem, ami a cpuid gepi utasitas altal vissazadott ertekekbol kivadassza a processzorok szamat, a magok szamat illetve a logikai processzorok szamat.

Irtam egy kis programot, amit le tudok forditani 32 es 64bites modban. lefuttatam a cegnel 1-2 gepen es a kovetkezoket adja vissza:


Pentium 4 (1 CPU (1core/CPU), Hyperthreading, 32bit):
CPIUD(0) --> eax=00000005, ebx=49656E69, ecx=6C65746E, edx=49656E69
Maximum input value for basic CPUID information = 5
Vendor identification string = 'GenuineIntel'

dump cpuid
CPIUD( 0) --> eax=00000005, ebx=49656E69, ecx=6C65746E, edx=49656E69
CPIUD( 1) --> eax=00000F43, ebx=BFEBFBFF, ecx=0000649D, edx=BFEBFBFF
CPIUD( 2) --> eax=605B5001, ebx=007D7040, ecx=00000000, edx=007D7040
CPIUD( 3) --> eax=00000000, ebx=00000000, ecx=00000000, edx=00000000
CPIUD( 4) --> eax=00004121, ebx=00000000, ecx=0000001F, edx=00000000
CPIUD( 5) --> eax=00000040, ebx=00000000, ecx=00000000, edx=00000000

logical processors in the physical package = 2
HTT-Multithreading flag                    = 1
logical processors sharing this cache      = 2
processor cores in the physical package    = 1
bye

Pentium Xeon (32bit, 4 CPU (1core/CPU), Hyperthreading):
CPIUD(0) --> eax=00000002, ebx=49656E69, ecx=6C65746E, edx=49656E69
Maximum input value for basic CPUID information = 2
Vendor identification string = 'GenuineIntel'

dump cpuid
CPIUD( 0) --> eax=00000002, ebx=49656E69, ecx=6C65746E, edx=49656E69
CPIUD( 1) --> eax=00000F11, ebx=3FEBFBFF, ecx=00000000, edx=3FEBFBFF
CPIUD( 2) --> eax=665B5001, ebx=007A7022, ecx=00000000, edx=007A7022

logical processors in the physical package = 2
HTT-Multithreading flag                    = 1
bye

Pentium Core 2 Duo (64bit, 1 CPU (2core/CPU)):
CPIUD(0) --> eax=0000000A, ebx=49656E69, ecx=6C65746E, edx=49656E69
Maximum input value for basic CPUID information = 10
Vendor identification string = 'GenuineIntel'

dump cpuid
CPIUD( 0) --> eax=0000000A, ebx=49656E69, ecx=6C65746E, edx=49656E69
CPIUD( 1) --> eax=000006F6, ebx=BFEBFBFF, ecx=0000E3BD, edx=BFEBFBFF
CPIUD( 2) --> eax=05B0B101, ebx=2CB4307D, ecx=00000000, edx=2CB4307D
CPIUD( 3) --> eax=00000000, ebx=00000000, ecx=00000000, edx=00000000
CPIUD( 4) --> eax=04000121, ebx=00000001, ecx=0000003F, edx=00000001
CPIUD( 5) --> eax=00000040, ebx=00000020, ecx=00000003, edx=00000020
CPIUD( 6) --> eax=00000001, ebx=00000000, ecx=00000001, edx=00000000
CPIUD( 7) --> eax=00000000, ebx=00000000, ecx=00000000, edx=00000000
CPIUD( 8) --> eax=00000400, ebx=00000000, ecx=00000000, edx=00000000
CPIUD( 9) --> eax=00000000, ebx=00000000, ecx=00000000, edx=00000000
CPIUD(10) --> eax=07280202, ebx=00000000, ecx=00000000, edx=00000000

logical processors in the physical package = 2
HTT-Multithreading flag                    = 1
logical processors sharing this cache      = 1
processor cores in the physical package    = 2
bye

Pentium M (32bit, 1 CPU (1core/CPU)):
CPIUD(0) --> eax=00000002, ebx=49656E69, ecx=6C65746E, edx=49656E69
Maximum input value for basic CPUID information = 2
Vendor identification string = 'GenuineIntel'

dump cpuid
CPIUD( 0) --> eax=00000002, ebx=49656E69, ecx=6C65746E, edx=49656E69
CPIUD( 1) --> eax=000006D8, ebx=AFE9FBFF, ecx=00000180, edx=AFE9FBFF
CPIUD( 2) --> eax=02B3B001, ebx=2C04307D, ecx=00000000, edx=2C04307D

logical processors in the physical package = 0
HTT-Multithreading flag                    = 0
bye

Udv,
Gabor

nem neztem ugyan utana, de van egy olyan erzesem, hogy cpuid-vel csak az adott processzorrol fogsz informaciot kapni, arrol hogy van-e tobb processzor a rendszerben es ha igen akkor mennyi, szerintem az aktualis OS-t kell megkerdezd.

+1. De ez logikus is: a CPU-ban lefut az utasítás, és a cpu megmondja, hogy ő milyen paraméterekkel bír. Arról, hogy az adott cpu mellett hány másik, tőle teljesen független fizikai cpu van, arról neki nem kell tudnia, és nem is tud, azt csak az os (vagy a bios?) tudná megmondani. Szerintem...