'top' output -> High CPU consumption when thread is in 'sleep' state

Q

qazmlp

The following is an excerpt from the 'top' output:
---------
PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
19828 tstUsr 25 47 4 899M 58M sleep 4:11 14.34%
bin.execRun
---------

The above state is after Thread.Sleep()(Java code) is invoked. I am
just wondering, how the thread which is in 'sleep' state consumes so
much i.e.14.34% of CPU.

Could anybody clarify this?
 
P

Paul Lutus

qazmlp said:
The following is an excerpt from the 'top' output:
---------
PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
19828 tstUsr 25 47 4 899M 58M sleep 4:11 14.34%
bin.execRun
---------

The above state is after Thread.Sleep()(Java code) is invoked. I am
just wondering, how the thread which is in 'sleep' state consumes so
much i.e.14.34% of CPU.

Could anybody clarify this?

Something is wrong with your program or your system. You have not posted any
code or revealed your OS, so all one can do is conjecture in obvious ways.

I just created a dummy program that calls Thread.sleep(15000) and watched my
"top" output on Fedora Core 2, no CPU-hogging activity here.

Maybe you could provide some information?
 
M

Mohun Biswas

qazmlp said:
The following is an excerpt from the 'top' output:
---------
PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
19828 tstUsr 25 47 4 899M 58M sleep 4:11 14.34%
bin.execRun
---------

The above state is after Thread.Sleep()(Java code) is invoked. I am
just wondering, how the thread which is in 'sleep' state consumes so
much i.e.14.34% of CPU.

Could anybody clarify this?

Can't help directly, but 'top' is deprecated on Solaris nowadays in
favor of the built-in 'prstat' program which provides largely the same
output. Try that and see if it's perhaps a problem with top itself
rather than your system.
 
F

Fredrik Lundholm

The following is an excerpt from the 'top' output:
---------
PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
19828 tstUsr 25 47 4 899M 58M sleep 4:11 14.34%
bin.execRun
---------

The above state is after Thread.Sleep()(Java code) is invoked. I am
just wondering, how the thread which is in 'sleep' state consumes so
much i.e.14.34% of CPU.

Could anybody clarify this?

The CPU usager percent is not an instant snapshot rather an average over some
time back. Wait some more and watch the value lower over time.

/Fredrik
 
D

Darren Dunham

In comp.unix.solaris qazmlp said:
The following is an excerpt from the 'top' output:
---------
PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
19828 tstUsr 25 47 4 899M 58M sleep 4:11 14.34%
bin.execRun
---------
The above state is after Thread.Sleep()(Java code) is invoked. I am
just wondering, how the thread which is in 'sleep' state consumes so
much i.e.14.34% of CPU.

The state is a snapshot at one point in time. The thread may have been
sleeping for a moment, but in general is running.

Also, the CPU time there is identical to the one in 'ps'. It represents
what is basically a weighted average of CPU consuption over the previous
few seconds (not quite, but pretty close).

So the process could consume CPU for 30 seconds, then sleep for
something like 40 to 50 seconds and you'd get a sleeping process that
has a CPU figure of 14% or so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top