Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to detect CPU architecture/bitmode (32-bit vs. 64-bit) for Linux

Reply
Thread Tools

How to detect CPU architecture/bitmode (32-bit vs. 64-bit) for Linux

 
 
bfische
Guest
Posts: n/a
 
      11-15-2005
Hi List members,

I have been trying to develop some code to figure out if a system is 32
or 64-bits.
I first thought about checking for the value of the Java System
Property "os.arch" but that doesn't help as it doesn't specify the
"bitness" of the processor.

I need to differentiate between a Linux on x86-32 bit or x86-64
(processor can be Intel or AMD) but I can't figure ou how.

uname -p seems to work (gives i686) but I am not sure this will always
return this (I don't have an AMD but I assume it will return a
different value).

Is there an OS command that print the hardware bit mode? (something
like getconf HARDWARE_BITMODE on AIX).

Thanks

 
Reply With Quote
 
 
 
 
Carl
Guest
Posts: n/a
 
      11-15-2005
bfische wrote:
> Hi List members,
>
> I have been trying to develop some code to figure out if a system is 32
> or 64-bits.
> I first thought about checking for the value of the Java System
> Property "os.arch" but that doesn't help as it doesn't specify the
> "bitness" of the processor.
>
> I need to differentiate between a Linux on x86-32 bit or x86-64
> (processor can be Intel or AMD) but I can't figure ou how.
>
> uname -p seems to work (gives i686) but I am not sure this will always
> return this (I don't have an AMD but I assume it will return a
> different value).
>
> Is there an OS command that print the hardware bit mode? (something
> like getconf HARDWARE_BITMODE on AIX).
>
> Thanks
>

bfische,

The i686 you noticed in the output of uname does not necessarily
indicate that the processor is or is not 64bit. Furthermore, the '-p'
switch is a non-standard option for the uname command.
http://www.opengroup.org/onlinepubs/...xcu/uname.html

You may want to look into parsing the contents of the /proc/cpuinfo
file, though this is far from a portable solution and may be implemented
differently in different platforms/distros.

Just out of curiosity, why would you want to know the processor type in
java?

Carl.
 
Reply With Quote
 
 
 
 
Thomas Fritsch
Guest
Posts: n/a
 
      11-15-2005
"bfische" <(E-Mail Removed)> wrote:
> I have been trying to develop some code to figure out if a system is 32
> or 64-bits.
> I first thought about checking for the value of the Java System
> Property "os.arch" but that doesn't help as it doesn't specify the
> "bitness" of the processor.

On my platform (Java 1.5.0, WinXP (32bit)) there is a java system property
sun.arch.data.model=32
I suspect this gives the "bitness" of the CPU.
(But be warned: You will enter the area of undocumented Sun-features)

--
"TFritsch$t-online:de".replace(':','.').replace('$','@')


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      11-15-2005
On 14 Nov 2005 17:02:47 -0800, "bfische" <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>Is there an OS command that print the hardware bit mode? (something
>like getconf HARDWARE_BITMODE on AIX).

try running wassup on a 64 bit machine to dump all the system
properties or write a little program to do that. See what turns up.
http://mindprod.com/applets/wassup.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
.
Guest
Posts: n/a
 
      11-15-2005
On Tue, 15 Nov 2005, Thomas Fritsch wrote:

> "bfische" <(E-Mail Removed)> wrote:
> > I have been trying to develop some code to figure out if a system is 32
> > or 64-bits.
> > I first thought about checking for the value of the Java System
> > Property "os.arch" but that doesn't help as it doesn't specify the
> > "bitness" of the processor.

> On my platform (Java 1.5.0, WinXP (32bit)) there is a java system property
> sun.arch.data.model=32
> I suspect this gives the "bitness" of the CPU.
> (But be warned: You will enter the area of undocumented Sun-features)


This will not give you the size of the CPU. This will give you the size of
the JVM. Just to confirm this, I just tried on an HP-UX running on an
Itanium2 (64 bit CPU) using a 32-bit JVM and sun.arch.data.model=32.

--
Send e-mail to: darrell dot grainger at utoronto dot ca

 
Reply With Quote
 
bfische
Guest
Posts: n/a
 
      11-24-2005
Hi Carl,

the reason why I am trying to detect the bitmode of the kernel is
because I am writing an installer. Based on the OS Kernel bitmode,
different set of libraries need to be laid down on the system.

it seems like the uname -m actually gives x86_64 when it is an x86
processor 64 bits (even for AMD processor). That's what I am using. I
hope it will work on all Linux platforms.

Carl wrote:
> bfische wrote:
> > Hi List members,
> >
> > I have been trying to develop some code to figure out if a system is 32
> > or 64-bits.
> > I first thought about checking for the value of the Java System
> > Property "os.arch" but that doesn't help as it doesn't specify the
> > "bitness" of the processor.
> >
> > I need to differentiate between a Linux on x86-32 bit or x86-64
> > (processor can be Intel or AMD) but I can't figure ou how.
> >
> > uname -p seems to work (gives i686) but I am not sure this will always
> > return this (I don't have an AMD but I assume it will return a
> > different value).
> >
> > Is there an OS command that print the hardware bit mode? (something
> > like getconf HARDWARE_BITMODE on AIX).
> >
> > Thanks
> >

> bfische,
>
> The i686 you noticed in the output of uname does not necessarily
> indicate that the processor is or is not 64bit. Furthermore, the '-p'
> switch is a non-standard option for the uname command.
> http://www.opengroup.org/onlinepubs/...xcu/uname.html
>
> You may want to look into parsing the contents of the /proc/cpuinfo
> file, though this is far from a portable solution and may be implemented
> differently in different platforms/distros.
>
> Just out of curiosity, why would you want to know the processor type in
> java?
>
> Carl.


 
Reply With Quote
 
jimmy jimmy is offline
Junior Member
Join Date: Sep 2008
Posts: 1
 
      09-18-2008
Quote:
Originally Posted by bfische
Hi List members,

I have been trying to develop some code to figure out if a system is 32
or 64-bits.
I first thought about checking for the value of the Java System
Property "os.arch" but that doesn't help as it doesn't specify the
"bitness" of the processor.

I need to differentiate between a Linux on x86-32 bit or x86-64
(processor can be Intel or AMD) but I can't figure ou how.

uname -p seems to work (gives i686) but I am not sure this will always
return this (I don't have an AMD but I assume it will return a
different value).

Is there an OS command that print the hardware bit mode? (something
like getconf HARDWARE_BITMODE on AIX).

Thanks

Its very simple bro...

type (in liniux cmd prompt) : cat /proc/cpuinfo
u will see some parameters with there discription

under "flags" parameter u will see various values.
Among them . u will find one of them with name "tm(transparent mode)" or
"rm(real mode)" or "lm(long mode)"
1. rm tells ,it is a 16 bit processor
2. tm tells, it is a 32 bit processor
3. lm tells, it is a 64 bit processor
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Is Netscape Leaving Firefox Behind on GNU/Linux? THE LINUX PROPAGANDA MACHINE CONTINUES. FIREFOX IGNORING LINUX............. traci.manicotti@gmail.com Computer Support 2 10-20-2007 02:12 PM
how to detect CPU architecture.. rrs.matrix@gmail.com C Programming 13 09-01-2006 09:41 PM
how to detect CPU architecture.. rrs.matrix@gmail.com C Programming 6 09-01-2006 03:24 PM
Linux... yeah linux.. Linux Have a nice cup of pee NZ Computing 19 04-17-2006 10:16 AM
Pentium CPU vs Intel Celeron CPU and the Wireless Mouse kirk lives! Computer Support 4 05-02-2004 06:59 PM



Advertisments