We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

How would I catch the Processor Id...???

mathursaurabh
on
Medium Priority
218 Views
Last Modified: 2010-04-15
Hello all,

I need to catch the CPU Unique Id for my applications' processing. Ay idea how I can do this...? I'm not an expert, but yes I am quite familiar with C.
Any help would be more than helpful.

Thanks
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2012
Commented:
On Intel/AMD, like

#pragma warning(disable:4035) // disable: 'function' : no return value

DWORD GetCPUID () {

#define cpuid __asm _emit 0xF0 0xA2   // hex opcode for CPUID
 __asm{
  xor eax, eax
  _emit 0xF0 0xA2
 }

 // return value is the content of EAX
}

#pragma warning(default:4035)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
>> _emit 0xF0 0xA2
Is this correct. As I know _emit can define a single byte.

By the way what the function is doing.
Can you please explain.
CERTIFIED EXPERT
Top Expert 2009

Commented:
Well, here's some nice info for IA-32 :

http://www.sandpile.org/ia32/cpuid.htm

from this site :

http://www.sandpile.org/
Commented:
It depends on what exact hardware and software you're running under.  

If you're running on the bare metal, with complete control of the code from CPU reset to your app, you can get at this info.

If there's a bootup BIOS in the way, it can turn off or fake this feature.

If you're running in protected or virtual 86 mode, the kernel can trap and fudge the results of this instruction.

Also there are many variations of the CPUID:  the original 486 CPUID, the Pentium "1" CPU ID, the AMD extended CPUID, the processor serial number CPUID, and more.    Which one are you looking for?




Artysystem administrator
Top Expert 2007

Commented:
"I need to catch the CPU Unique Id for my applications' processing"
What OS and what hardware are you using?

BTW your application may not be shure that it's running on specific CPU, even when you reach next line of your C application.

Author

Commented:
> On Intel/AMD, like
>
>#pragma warning(disable:4035) // disable: 'function' : no return value
>
>DWORD GetCPUID () {
>
>#define cpuid __asm _emit 0xF0 0xA2   // hex opcode for CPUID
> __asm{
>  xor eax, eax
>  _emit 0xF0 0xA2
> }
>
> // return value is the content of EAX
>}
>
>#pragma warning(default:4035)

Thanks for the response jkr, but I am confused how am I supposed to use the folowing code snippet..?? Can you please details it a btit more..??
Also if you can let me know how to call a C file from with-in a shell script while your .rpm package is getting installed. This C file would provide the necessary inout to the shell script which would then forward this input to the installing software. Any clue on this...??


Thanks
Commented:
There's a pretty good tutorial on the use of the CPUID at http://www.paradicesoftware.com/specs/cpuid/index.htm
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.