[PLUG] high cpu utilization

Abhijit Bhopatkar bain at devslashzero.com
Fri Nov 13 12:01:18 IST 2009


> > In my C program, I have two threads,
<snip>
> >   This I try fixing by putting a usleep in the while loop , hence there
> > is a small decrease in cpu utilization.
> 
> Create a pipe. Write data into that pipe from thd_r. In thd_w, you can
> do a blocking read on the pipe.

No, you don't want to do that, 
Passing data around pipes is expensive, you might as well busy spin in write 
thread. (yes there is always a splice syscall to do a zero copy op, but its 
complicated and not needed, all we need here is a conditional variable).

BAIN




More information about the Plug-mail mailing list