LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 01-20-2005, 11:56 PM   #1
sumit_sinha
LQ Newbie
 
Registered: Jan 2005
Posts: 2

Rep: Reputation: 0
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.
 
Old 01-21-2005, 12:20 AM   #2
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
I have a single CPU system but I think this will work. At least tell you if it sees them all.

Code:
cat /proc/cpuinfo
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

 
Old 01-21-2005, 12:31 AM   #3
Libu
Member
 
Registered: Oct 2003
Location: Chennai
Distribution: Slackware 12.1
Posts: 165

Rep: Reputation: 36
No. of CPU

Is information from top enuf for you ?

Code:
$\> top
 
Old 01-21-2005, 01:24 AM   #4
sumit_sinha
LQ Newbie
 
Registered: Jan 2005
Posts: 2

Original Poster
Rep: Reputation: 0
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
 
Old 01-21-2005, 01:35 AM   #5
Libu
Member
 
Registered: Oct 2003
Location: Chennai
Distribution: Slackware 12.1
Posts: 165

Rep: Reputation: 36
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.
 
Old 01-21-2005, 01:45 AM   #6
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
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

 
Old 01-21-2005, 01:59 AM   #7
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
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.

 
Old 01-21-2005, 02:25 AM   #8
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
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

 
Old 03-29-2011, 09:57 AM   #9
vashar
LQ Newbie
 
Registered: Mar 2011
Posts: 1

Rep: Reputation: 0
hi

Try one og these:

htop


or

cat /proc/cpuinfo | grep processor | wc -l



good luck!
 
Old 03-29-2011, 10:15 AM   #10
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 19,594

Rep: Reputation: 3510Reputation: 3510Reputation: 3510Reputation: 3510Reputation: 3510Reputation: 3510Reputation: 3510Reputation: 3510Reputation: 3510Reputation: 3510Reputation: 3510
ARGGGH - don't reserrect 5 year old dead threads.
<post deleted>

Last edited by syg00; 03-29-2011 at 10:20 AM.
 
Old 03-29-2011, 10:24 AM   #11
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,237

Rep: Reputation: 1656Reputation: 1656Reputation: 1656Reputation: 1656Reputation: 1656Reputation: 1656Reputation: 1656Reputation: 1656Reputation: 1656Reputation: 1656Reputation: 1656
Quote:
Originally Posted by sumit_sinha View Post
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.
 
Old 03-29-2011, 10:53 AM   #12
toordog
Member
 
Registered: Jul 2010
Location: Montreal, Canada
Distribution: RedHat, Ubuntu, Solaris, AIX, BSD
Posts: 42

Rep: Reputation: 3
Quote:
Originally Posted by szboardstretcher View Post
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.)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get cpu information on Linux machine laxmi_cs Programming 41 03-05-2013 02:55 AM
how to connect Linux machine with Window Active Directory hanybeee Linux - Networking 1 10-22-2005 04:16 PM
Multithreaded System On 4 Cpu Linux Machine, process stuck on certain thread eyalzm Programming 1 05-10-2004 11:46 AM
Which command would reveal amount of CPU's running on current machine? VotTak Linux - Hardware 7 01-20-2004 10:59 PM
Switching off a CPU of a multiple CPU machine kravisudhakar Linux - General 1 12-26-2003 10:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration