Solved

processors count

Posted on 2013-05-29
7
261 Views
Last Modified: 2013-06-11
hi guys

I am trying to find out how many processors i have in my Production server. i am using this code
Runtime.getRuntime().availableProcessors();

but does that give a correct count of the number of processors?

What if i have 2 boxes in a cluster and each box has one processor, will the
above code return me correct number of processors.

thanks
0
Comment
Question by:royjayd
  • 4
  • 2
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39205225
What hardware/software would you have that would allow clustering of processors?
0
 
LVL 16

Expert Comment

by:Valeri
ID: 39206844
No. I think you mean "nodes" when you write "boxes" in the cluster?! Am I right?
If this is the case then "Runtime.getRuntime().availableProcessors();" will be executed on each one of the boxes, because each box runs it's own JVM.
Btw Runtime.getRuntime().availableProcessors(); returns number of the cores of the processor, in your case if you have 1 processor with 4 cores, the returnd value will be "4".
0
 

Author Comment

by:royjayd
ID: 39207627
well the problem is i asked my system admin how many CPUs we are using in Production environment and he says 4
but my java code  
>>Runtime.getRuntime().availableProcessors();

returns 1

so i am not sure why there is a mismatch.
However one thing i am pretty sure is it is a production box and it cannot have just one cpu.
so as per my system admin 4 cpus sounds about right.

Thx.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:CEHJ
ID: 39208126
What OS are you using?
0
 

Author Comment

by:royjayd
ID: 39208138
Linux OS on production box , no application servers.
Its just a single java program running in one single jvm.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 325 total points
ID: 39208220
cat /proc/cpuinfo

Open in new window

Would be worth trying. Java uses

sysconf(_SC_NPROCESSORS_CONF)

Open in new window


http://www.gnu.org/software/libc/manual/html_node/Processor-Resources.html

You might also need to look at ulimit and quota
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39239616
:)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
solarwind tftp server 2 45
Where to store the queries for modification of table 4 55
ForLoop Example 3 40
tomcat administrtor 12 32
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

896 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now