


#Osx proc cpuinfo code
Please note that I'm not certain about the x86_64 bit above in theory what I've typed there will ensure that the same code compiles for 64-bit, and will return a 64-bit value in that case. _private_extern_ unsigned long GetSteppingID( void ) * unsigned long is register-sized on both 32-bit and 64-bit OS X */ Leave // restores prior stack frame from %ebp Mov %edx,%eax // %eax is 32-bit arch result register (Note that they all have the same physical id.).

Mov %edx,%rax // %rax is 64-bit arch result register The entries are logical processors objects used by the kernel internally, not necessarily tied to physical devices. It will regard 'anything' that can take care of one process at a time as a processor. Push %ebx // we save %ebx because the cpuid instructionĬpuid // stepping-id is in low 4 bits of %edx nowĪnd $0x0000000f,%edx // clear out everything we don't want The cpuinfo report abstracts out the fact that each physical processor (one of several cpu's on a die) can expand its computing powers by tech feats such as multithreading. Mov %esp,%ebp // make a new frame pointer from stack pointer Push %ebp // store existing frame pointer _private_extern_ unsigned long GetCPUSteppingID( void ) If that doesn't include a stepping ID, the only way I can think of to obtain that (off the top of my head) is via the CPUID instruction. This will return a structure containing cpu type and subtype codes along with C-string names and descriptions. Next, you can get processor info using the NXArchInfo() call obtained by including. If you're reading these via IOKit however, you'll get back a CFDataRef, and can just copy the bytes into your own uint32_t like so: uint32_t bus_frequency = 0 ĬFDataGetBytes( theData, (UInt8 *) &bus_frequency, sizeof(uint32_t) ) We should at least add a fallback like sysctl -n hw.ncpu or very fancy python -c 'import multiprocessing as mp print(mp.cpucount())' (from. timebase-frequency: 1000000000 HZ => 1.0 GHz On AzP OSX image the enforce script still tries to read /proc/cpuinfo leading to: cat: /proc/cpuinfo: No such file or directory +++ cpus' 0' +++ export B2JOBS1 +++ B2JOBS1.'bus-frequency' and 'clock-frequency', and 'timebase-frequency' are all 32-bit integers wrapper in data objects, and must therefore be byte-swapped to interpret here (little-endian i386 machine words), and work out to the following values: Selecting either one gets me the following information: The IORegistryExplorer application (part of the standard devtools installation) will help you locate what you're looking for.įor instance, on my MacBook Pro, in IORegistryExplorer I select 'IODeviceTree' from the pull-down at the top-left of the window, and I can see two CPUs in the tree view below.
