Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Finding idle process time in unix
Hi,

I want to know the idle time (time spent in wait + ready to run
queue)  for a process on unix.

One way I thought was to take the start time and end timein a process
(using gettimeofday()) and subtract the cpu time (returned by
clock() ) from their difference, this will fairly be equal to the
total idle time of the process.

Is there any better day using system calls/kernel data structure
which
can be used for the purpose.

Thanks in advance

Report this thread to moderator Post Follow-up to this message
Old Post
Rahul
03-27-08 12:43 AM


Re: Finding idle process time in unix
> Is there any better day using system calls/kernel data structure
> which
> can be used for the purpose.

Since getrusage() will give you only user time and sys time and not
the real time, you may want to access the proc structure or (yep it's
ugly, you can use our old good friend ps command).

-- paulo

Report this thread to moderator Post Follow-up to this message
Old Post
ppi
03-27-08 12:43 AM


Re: Finding idle process time in unix
Rahul wrote:
> I want to know the idle time (time spent in wait + ready to run
> queue)  for a process on unix.
>
> One way I thought was to take the start time and end timein a process
> (using gettimeofday()) and subtract the cpu time (returned by
> clock() ) from their difference, this will fairly be equal to the
> total idle time of the process.
>
> Is there any better day using system calls/kernel data structure
> which
> can be used for the purpose.

As long as we're on that subject, I'm curious if there's a way
(either a portable way, or a way that works on Linux) to find
a related quantity, which could also be called "idle time", but
which is how long it has been since a given process has been
scheduled on a CPU.

As I recall, the "ps" command on SunOS 4.x could give this
information, and a little googling indicates that the "ps"
command on FreeBSD can do it as well (with something like
"ps -v").

It was a really handy thing to have when something strange had
happened recently (like a file was deleted, a packet was sent
or received) and you wanted to see what the likely culprits
were:  just sort processes by the time since they last run,
and the culprit either has to be one of those in the right
time frame (or has to have already exited -- and had its exit
status reaped by a wait()er, which could be an accomplice).

- Logan

Report this thread to moderator Post Follow-up to this message
Old Post
Logan Shaw
03-27-08 03:52 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 02:41 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.