[PLUG] high cpu utilization
bain at devslashzero.com
Thu Nov 12 22:31:18 PST 2009
> > In my C program, I have two threads,
> > 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).
More information about the plug-mail