>
>
> Latency is worse than using mwait because you are sleeping unconditionally.
> Mwait does not prevent you from getting the interrupt to schedule.
>
>
By this I mean that mwait unblocks on interrupt. You could do something
like
(you do exponential backoff calling sleep or sleep/wakeup in the kernel)
one out of N where N
goes from big to 1 as the count increases:
while(1){
mwait(&l->mwaitvar);
test_the_var_and break();
sleep(0); //one out of N iterations
}
This will make the the process consume a little part of the quantum (until
the next tick) waiting, and most
of that time the processor is turned off or at least consuming less.
G.