?
Solved

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

Posted on 2006-03-27
9
Medium Priority
?
206 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
0
Comment
Question by:mathursaurabh
7 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 172 total points
ID: 16302234
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)
0
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 16307712
>> _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.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 16308399
Well, here's some nice info for IA-32 :

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

from this site :

http://www.sandpile.org/
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 22

Assisted Solution

by:grg99
grg99 earned 164 total points
ID: 16310129
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?




0
 
LVL 27

Expert Comment

by:Nopius
ID: 16328327
"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.
0
 

Author Comment

by:mathursaurabh
ID: 16374885
> 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
0
 
LVL 41

Assisted Solution

by:graye
graye earned 164 total points
ID: 16449407
There's a pretty good tutorial on the use of the CPUID at http://www.paradicesoftware.com/specs/cpuid/index.htm
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question