Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-20-2005, 11:56 PM
|
#1
|
LQ Newbie
Registered: Jan 2005
Posts: 2
Rep:
|
How to find how many CPU's are active in 8 CPU Linux machine
HI ,
I am working on 8 CPU Linux machine but in one scenario I need to test the application using only 2 CPU.
Is there any command through which we can know how many CPU's are active in a machine.
To check for the CPU count on linux I used TOP command but without any result.
I will be greatful if any one can provide the solution.
Thanks.
|
|
|
01-21-2005, 12:20 AM
|
#2
|
Senior Member
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Rep:
|
I have a single CPU system but I think this will work. At least tell you if it sees them all.
At worst you will get a file does not exist. That will only read the file.
If you have a GUI, gkrellm I think supports multiple CPUs too. Not 100% sure though.
Wish I had one of those.
Later

|
|
|
01-21-2005, 12:31 AM
|
#3
|
Member
Registered: Oct 2003
Location: Chennai
Distribution: Slackware 12.1
Posts: 165
Rep:
|
No. of CPU
Is information from top enuf for you ?
|
|
|
01-21-2005, 01:24 AM
|
#4
|
LQ Newbie
Registered: Jan 2005
Posts: 2
Original Poster
Rep:
|
The cat /proc/cpuinfo will give me complete details of the processor.
Let me put the question in other way...
Out of the 8 CPU i want to bind only 2 CPU & after binding I want to confirm if only the required CPU are active..
The test will be running should be handled by only 2 CPU.
So, is there any way to know the active cpu count..
The TOP is not able to solve my problem..
Hope I am able to put question in proper way..
Thanks

|
|
|
01-21-2005, 01:35 AM
|
#5
|
Member
Registered: Oct 2003
Location: Chennai
Distribution: Slackware 12.1
Posts: 165
Rep:
|
I am not sure whether you can restrict the number of CPU's being used on aserver !! Since there are system processes that will continuously run and some that run whenever, I dont think there is cock-sure way of restricting the number of active CPUs !!
Not an authority on this, just my two cents.
|
|
|
01-21-2005, 01:45 AM
|
#6
|
Senior Member
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Rep:
|
According to "The Screen Savers", TV show here in the USA, that can be done and you can assign the processes to a specific CPU. I have no clue how though. I just remember seeing Leo do that during a Linux how too. It was a good while back too.
I'll search around. No promises though.
Later

|
|
|
01-21-2005, 01:59 AM
|
#7
|
Senior Member
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Rep:
|
Check this out.
http://www.tldp.org/HOWTO/SMP-HOWTO-3.html
Still digging. The part you might need to read is close to the bottom. You may also see the command I posted earlier. Since it sees the CPU, all of them I hope, you can skip the part about the kernel. It is there or it would not list them.
I have no experience with this. I'm just using google for Linux and pointing. If some guru that has knowledge of this and how it works and posts, then I'll stop diggin. All I can do.

|
|
|
01-21-2005, 02:25 AM
|
#8
|
Senior Member
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Rep:
|
OK, this is all I could find. This one has a little tip on top and how to show all CPUs seperately.
http://www.linuxquestions.org/questi...hreadid=120621
This is another program that show usage:
http://icm.linux.tucows.com/preview/8483.html
There is also a program called wmfire that you can look for if the others don't work. The command top with the little trick mentioned in the other link should work though. I think all Linux distro's include top.
Google ran out of hits so I'm out too. Hope that helps a bit or somebody that has one comes along.
Later

|
|
|
03-29-2011, 09:57 AM
|
#9
|
LQ Newbie
Registered: Mar 2011
Posts: 1
Rep:
|
hi
Try one og these:
htop
or
cat /proc/cpuinfo | grep processor | wc -l
good luck!
|
|
|
03-29-2011, 10:15 AM
|
#10
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,414
|
ARGGGH - don't reserrect 5 year old dead threads.
<post deleted>
Last edited by syg00; 03-29-2011 at 10:20 AM.
|
|
|
03-29-2011, 10:24 AM
|
#11
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
Quote:
Originally Posted by sumit_sinha
HI ,
I am working on 8 CPU Linux machine but in one scenario I need to test the application using only 2 CPU.
Is there any command through which we can know how many CPU's are active in a machine.
To check for the CPU count on linux I used TOP command but without any result.
I will be greatful if any one can provide the solution.
Thanks.
|
Easy.
If you know the PID for the task, then use taskset, which will bind the task to only 2 processors.
Code:
taskset -pc 0,1 4905
0,1 are the processor numbers
4905 is the PID of the program[COLOR="Silver"]
I see now that this is an old thread -- but it didn't have an answer. Now it does.
Last edited by szboardstretcher; 03-29-2011 at 10:25 AM.
|
|
|
03-29-2011, 10:53 AM
|
#12
|
Member
Registered: Jul 2010
Location: Montreal, Canada
Distribution: RedHat, Ubuntu, Solaris, AIX, BSD
Posts: 42
Rep:
|
Quote:
Originally Posted by szboardstretcher
Easy.
If you know the PID for the task, then use taskset, which will bind the task to only 2 processors.
Code:
taskset -pc 0,1 4905
0,1 are the processor numbers
4905 is the PID of the program[COLOR="Silver"]
I see now that this is an old thread -- but it didn't have an answer. Now it does.
|
I'd like to add that taskset is not always installed by default and is part of the package schedutils
I second the solution, this thread is now solved hehehe (6 years later.)
|
|
|
All times are GMT -5. The time now is 10:59 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|