Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I don't understand why the following increases cpu time

1 view
Skip to first unread message

grocery_stocker

unread,
Jan 8, 2008, 9:31:25 PM1/8/08
to
If I do the following...

% cat < /dev/zero

And look at top, nothing shows ups.....

last pid: 83551; load averages: 1.82, 1.64, 1.38 up
49+10:45:28 21:26:16
217 processes: 2 running, 182 sleeping, 1 stopped, 32 zombie

Mem: 139M Active, 632M Inact, 164M Wired, 33M Cache, 111M Buf, 28M
Free
Swap: 512M Total, 512M Free


PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU
COMMAND
279 buttemb 1 129 5 3212K 1808K RUN 241.8H 17.29% bash
82205 vrana 1 5 5 7228K 5168K ttyin 0:00 2.45% lynx
50756 serapis 1 5 5 8380K 6320K ttyin 0:02 1.90% lynx

However, if I change it so /dev/zero goes to /dev/nulll

m-net% cat < /dev/zero > /dev/null


And then look at top, I see that I'm taking up 52.08% CPU time...

last pid: 48206; load averages: 1.44, 1.24, 1.20 up
49+10:41:45 21:22:33
215 processes: 4 running, 179 sleeping, 1 stopped, 31 zombie

Mem: 136M Active, 632M Inact, 164M Wired, 33M Cache, 111M Buf, 31M
Free
Swap: 512M Total, 512M Free


PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU
COMMAND
47506 cdalten 1 127 5 1272K 652K RUN 0:05 52.08% cat
279 buttemb 1 128 5 3212K 1808K RUN 241.8H 16.11% bash
43171 vrana 1 5 5 7844K 5832K ttyin 0:02 5.75% lynx

The question why does copying to /dev/null make a sharp increas in CPU
time.

Barry Margolin

unread,
Jan 9, 2008, 1:04:42 AM1/9/08
to
In article
<1f8cf61d-933a-4171...@q39g2000hsf.googlegroups.com>,
grocery_stocker <cda...@gmail.com> wrote:

> If I do the following...
>
> % cat < /dev/zero
>
> And look at top, nothing shows ups.....
>
> last pid: 83551; load averages: 1.82, 1.64, 1.38 up
> 49+10:45:28 21:26:16
> 217 processes: 2 running, 182 sleeping, 1 stopped, 32 zombie
>
> Mem: 139M Active, 632M Inact, 164M Wired, 33M Cache, 111M Buf, 28M
> Free
> Swap: 512M Total, 512M Free
>
>
> PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU
> COMMAND
> 279 buttemb 1 129 5 3212K 1808K RUN 241.8H 17.29% bash
> 82205 vrana 1 5 5 7228K 5168K ttyin 0:00 2.45% lynx
> 50756 serapis 1 5 5 8380K 6320K ttyin 0:02 1.90% lynx

When you write to the terminal, the speed of the terminal throttles how
quickly cat can run.

> However, if I change it so /dev/zero goes to /dev/nulll
>
> m-net% cat < /dev/zero > /dev/null
>
>
> And then look at top, I see that I'm taking up 52.08% CPU time...
>
> last pid: 48206; load averages: 1.44, 1.24, 1.20 up
> 49+10:41:45 21:22:33
> 215 processes: 4 running, 179 sleeping, 1 stopped, 31 zombie
>
> Mem: 136M Active, 632M Inact, 164M Wired, 33M Cache, 111M Buf, 31M
> Free
> Swap: 512M Total, 512M Free
>
>
> PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU
> COMMAND
> 47506 cdalten 1 127 5 1272K 652K RUN 0:05 52.08% cat
> 279 buttemb 1 128 5 3212K 1808K RUN 241.8H 16.11% bash
> 43171 vrana 1 5 5 7844K 5832K ttyin 0:02 5.75% lynx

The /dev/null driver is very efficient, since it doesn't have to do
anything. This allows cat to run at full speed and use more CPU time.

> The question why does copying to /dev/null make a sharp increas in CPU
> time.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

0 new messages