<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Pravin Shedage wrote:
<blockquote
cite="mid:AANLkTi=HAw8uu=2ipwDSrn325whYAtGJbCZFCEC9WY-M@mail.gmail.com"
type="cite">Hi,<br>
<br>
This C program might help you.<br>
<br>
#include <stdio.h><br>
#include <stdlib.h><br>
#include <string.h><br>
#include <errno.h><br>
#include <sys/utsname.h><br>
<br>
int main()<br>
{<br>
struct utsname *buf = NULL;<br>
<br>
<br>
<br>
buf = malloc(sizeof(struct utsname));<br>
if (buf == NULL) {<br>
fprintf(stderr,"Memory Allocation Error: %s \n",
strerror(errno));<br>
exit(-1);<br>
}<br>
<br>
if (uname(buf) < 0) {<br>
fprintf(stderr,"UName Error: %s \n", strerror(errno));<br>
exit(-1);<br>
}<br>
<br>
printf ("Processor arch =:>) %s \n", buf->machine);<br>
<br>
return 0;<br>
}<br>
<br>
<br>
<br>
<br>
<div class="gmail_quote">On Thu, Jan 27, 2011 at 4:45 PM, Henry
Gebhardt <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:hsggebhardt@googlemail.com">hsggebhardt@googlemail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Thu, Jan 27, 2011 at 03:23:28PM +0530, prabhu
wrote:<br>
> Any C programming technique apart from using this /proc/cpuinfo
detail?<br>
<br>
</div>
What about using the machine field of uname(2):<br>
<br>
$ man 2 uname<br>
<br>
Quoting from that man page:<br>
<br>
[...] the operating system presumably knows its name, release<br>
and version. It also knows what hardware it runs on.<br>
<br>
Perhaps a downside, it returns the machine type as a string. Does that<br>
do what you want?<br>
<br>
I also find "man linux32" rather interesting:<br>
<br>
setarch - change reported architecture in new program environment<br>
and set personality flags<br>
<br>
Might be useful for testing.<br>
<br>
<br>
Greetings,<br>
<font color="#888888">Henry<br>
</font>
<div>
<div class="h5"><br>
</div>
</div>
</blockquote>
</div>
</blockquote>
<br>
<small>Both Ideas give the Kernel architecture not cpu architecture. <br>
<br>
You can get exact cpu architecture through lshw command.<br>
<br>
*-cpu<br>
product: Intel(R) Pentium(R) Dual CPU E2160 @ 1.80GHz<br>
vendor: Intel Corp.<br>
physical id: 1<br>
bus info: cpu@0<br>
version: 6.15.13<br>
serial: 0000-06FD-0000-0000-0000-0000<br>
size: 1200MHz<br>
capacity: 1200MHz<br>
<font color="#000066"> <font color="#cc0000">width: 64 bits</font></font><br>
capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce
cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2
ss ht tm pbe nx x86-64 constant_tsc arch_perfmon pebs bts pni dtes64
monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm cpufreq<br>
configuration: id=1<br>
*-logicalcpu:0<br>
description: Logical CPU<br>
physical id: 1.1<br>
width: 64 bits<br>
capabilities: logical<br>
*-logicalcpu:1<br>
description: Logical CPU<br>
physical id: 1.2<br>
width: 64 bits<br>
capabilities: logical</small><br>
<br>
<blockquote
cite="mid:AANLkTi=HAw8uu=2ipwDSrn325whYAtGJbCZFCEC9WY-M@mail.gmail.com"
type="cite">
<div class="gmail_quote">
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div class="h5">_______________________________________________<br>
Kernelnewbies mailing list<br>
<a moz-do-not-send="true"
href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a moz-do-not-send="true"
href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies"
target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<br>
<br>
Thanks & Regards,<br>
---------PraviN---------<br>
<br>
<br>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Kernelnewbies mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a>
<a class="moz-txt-link-freetext" href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a>
</pre>
</blockquote>
<br>
</body>
</html>