Operating System - HP-UX
1833184 Members
2797 Online
110051 Solutions
New Discussion

Re: What's the reason program uses too much realtime CPU?

 
mzou
Occasional Contributor

What's the reason program uses too much realtime CPU?

The code which modify process's priority is
int pmin = sched_get_priority_min(schedPolicy);
int pmax = sched_get_priority_max(schedPolicy);
threadParam.sched_priority = pmin + (pmax - pmin)/2;
pthread_attr_setschedparam(&threadAttr,&threadParam);
pthread_create(&thrId,&threadAttr,__run,(void*)this);


After thread started, there is no program to modify priority.
While process running, realtime CPU became so high and also block all the other processes.

Sec Alive Process User Interest Stop SysCall Normal Nice RealTm CSwtch Intrpt Logl Logl Phys FileIO VM System IO Byte Res Virtual Thread Pri DskSubsys Sem LAN Memory
Date Time /Intvl Intvl PID Name Name Pri Reason Reason CPU % CPU % CPU % CPU % CPU % CPU % CPU % Rd Rt Wr Rt IO Rt Rate IO Rt IO Rt Rate Mem Memory Count Wait % Wait % Wait % Wait % Wait %
07/12/06 16:07 60 60.13 5532 notifier mzou 65520 C SLEEP 100.02 0.00 0.00 0.00 99.28 0.01 0.73 0 0 0.4 0.4 0.0 0.0 4.2 5600 9064 3 0.00 0.00 0.00 0.00 0.00
07/12/06 16:08 60 60.10 19480 java innopath 168 DM SLEEP 0.04 0.00 0.00 0.00 0.00 0.01 0.04 113 0 6.3 1.4 0.0 4.9 22.8 198656 797696 101 0.01 0.00 0.00 0.00 0.00
07/12/06 16:08 60 60.10 24363 java innopath 220 C M PRI 8.52 1.00 7.00 0.00 0.00 0.01 0.51 532 0 0.1 0.1 0.0 0.0 1.5 311296 761856 60 0.09 0.00 0.00 0.00 0.00
07/12/06 16:08 60 60.10 24747 java navis 168 M SLEEP 0.08 0.00 0.00 0.00 0.00 0.00 0.08 0 1 0.3 0.3 0.0 0.0 2.9 82944 704512 41 0.01 0.00 0.00 0.00 0.00
07/12/06 16:08 60 60.10 5532 notifier mzou 65520 C SYSTM 100.52 0.00 0.00 0.00 99.88 0.01 0.63 0 0 0.2 0.2 0.0 0.0 2.6 5600 9064 3 0.00 0.00 0.00 0.00 0.00


4 REPLIES 4
Steven E. Protter
Exalted Contributor

Re: What's the reason program uses too much realtime CPU?

Shalom,

Lots of possible reasons a proram uses too much cpu.

Not in any order

1) Nothing else on the system needs cpu, which means if nothing else needs it the program that requests cpu gets cpu.
2) A poorly written program is binding itself to the CPU or otherwise hogging resources.
3) The NICE priority on the program is a low number giving it a high priority relative to other processes.

Just a samping.

Bad code need to be dealt with by programmers or app vendors.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
mzou
Occasional Contributor

Re: What's the reason program uses too much realtime CPU?

What's interesting, Normal and System CUP rate are low. normal poor code could do this?

CPU(%) 100.0
SysCall(%) 0.00
Normal(%) 0.00
Nice(%) 0.00
RealTm(%) 99.28
CSwtch(%) 0.01
Intrpt(%) 0.73

some ducoment says "Running at a realtime priority means that the process has run using the rtprio command or the rtprio system call to alter its priority."

Kent Ostby
Honored Contributor

Re: What's the reason program uses too much realtime CPU?

mzou ... depending on the permissions you are giving your code then it could be eating all the cpu. If you are running as non-zero UID then it shouldn't unless you've used root capabilities to modify it.

Oz
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Mancboy
Valued Contributor

Re: What's the reason program uses too much realtime CPU?

It looks like the priorities are mismatched.
I was told many years ago to not renice processes in modern systems - this was a long time ago, so I must be getting very old :-(

Some programs though, I've seen by default, renice themselves - and as a result cause context switching as we see here.

Make sure that the processes are all the default nice value (quick check in top should show them all as 20).

All your system is doing, is using all it's CPU time, trying to give your notifier program extra CPU time. Change its nice value to be 20 and it should all work fine.