Linux – Why does a CP command on linux consume CPU

central-processing-unitcopyhard driveiolinux

I just run a copy command for two large directories with a small number of huge files and I see my cp process is consuming around half a core in top:

51116 root      20   0  110m  876  688 D 43.9  0.0   3:23.83 cp -i -r 165 178 temp       

Why does the cp process consume any cpu? I would imagine it spends most of it's time waiting on disk…

Thx,
Boaz

Best Answer

if you check the percentages, at the top of the screen, you'll see that it's mostly on %wa (waiting) and %id (idle), and very little (if any) in %us(userspace).

but at the process line, all the time it spends idly waiting for a given process is charged to that process. if another CPU-heavy process was running at the same time, it would take most of the CPU without affecting the copy task, because it would use the %id and %wa time.