Bruce Dawson wrote:
> Hmmm -- again, that doesn't match what I see. bash is suspended while it
> waits for expr to run, and the instant that expr completes bash runs again.
> This can be seen in the profiler screenshot. The CPU is busy at all times,
> and always busy on exactly one process.
---
        I don't see that on my system.

I ran
exprcount() {
 for (( i=$1;i>0;i=$(expr $i-1) )); do :; done
 }
time exprcount 1000
2.05sec 0.12usr 1.33sys (71.12% cpu)
Ishtar:law/bin> time exprcount 10000
20.43sec 1.62usr 12.98sys (71.48% cpu)
---
But 'top' never shows over 20% usage , vs.

 function f { i=10000000;while ((i--));do :; done ;}
time  f
31.73sec 29.25usr 2.41sys (99.76% cpu)

and top shows 100% cpu usage for 'f'

i.e. My system seems to include scheduling time (or a large part of it)
as part of the 'time' figures.

Note..  you said your loop took 2 seconds on your 3.2GHz sys.

My system was idling at 1.6GHz nearly the whole test.


It's your kernel settings that are causing issue.

Reply via email to