In case 1, you're essentially asking Perl to, as fast as it
can, keep checking to see if a key has been pressed. This
means that your program is constantly in a 'Run' state,
unless forced to give up the CPU for another program.
In fact, that's what's helping to cap the process's CPU
utilization. The scheduling algorithm (one of them, anyway - Solaris has several) in the kernel is
forcing your program to temporarily give up the CPU,
and your process is being rescheduled with a lower priority
because it's asking to do so much, meaning it'll take it
an extra bit of time to make its way back onto the CPU.
If you voluntarily give up the CPU, by blocking on a
resource or by sleep()ing, you get scheduled with a higher
priority than those who don't. Which is another factor
leading toward why your keyboard response times don't drop -
processes that spent a lot of time blocked on IO functions
manage to get higher priority.
Hope this serves to illuminate...
--
jwest
-><- -><- -><- -><- -><-
All things are Perfect
To every last Flaw
And bound in accord
With Eris's Law
- HBT; The Book of Advice, 1:7