LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 12-18-2008, 06:40 AM   #1
kamaalhassan
LQ Newbie
 
Registered: Dec 2008
Posts: 2

Rep: Reputation: 0
Need to write a code in C to find the top 10 process which are utilizing most of the


Hey I have to make a tool to monitor the top 10 processes utilizing the most of the CPU. Need to write a c code.. can any one help from which system file I can read the cpu utilization. tried getting info from proc/<pid>/stat statm status .
 
Old 12-18-2008, 07:01 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
Is this a homework assignment?

What happened when you looked at those files in /proc? Do you have the format that describes what they contain?

Have you looked at the "top" command?
 
Old 12-18-2008, 07:20 AM   #3
fiomba
Member
 
Registered: Sep 2004
Posts: 63

Rep: Reputation: 15
you don't need c programming... only a shell command...
Code:
ps aux|sort -k3 |tail
 
Old 12-18-2008, 09:01 AM   #4
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,919

Rep: Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779
...and as this is an open source OS, you can increase your understanding of how these things are done by looking at the source code of something that does it...

Hope that helps with the homework!
 
Old 12-19-2008, 01:37 AM   #5
kamaalhassan
LQ Newbie
 
Registered: Dec 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks

Thanks for the response but I need to write a c code for getting the top 10 processes that are using the most cpu..
/proc/<PID>/ folder contains folder like stat statm status which contains a lot of information like utime stime ....
Can I use these info to calculate the cpu usage?
 
  


Reply

Tags
cpu, process, top, utilization


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to wait for the process and know if the exit code of the sub process williamhomanchun Linux - General 10 08-11-2008 02:32 PM
How do I find the process details from the C code Manjunath1847 Linux - General 3 07-18-2008 07:45 AM
To find the process that uses the most memory using top nano2 Linux - Server 2 06-12-2008 11:02 AM
top process full path toolshed Linux - Software 7 02-01-2005 05:45 PM
Can't see process with ps or top Lemon Songster Linux - Newbie 0 10-23-2004 09:52 AM


All times are GMT -5. The time now is 09: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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration