From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <0A651ACE-ADD2-4C9F-9491-0802B20923B9@gmail.com> References: <9d4d16071350d120a79044a6c0c1604f@felloff.net> <0A651ACE-ADD2-4C9F-9491-0802B20923B9@gmail.com> Date: Thu, 19 Dec 2013 15:16:25 +0100 Message-ID: From: Gorka Guardiola To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=047d7bd770228af1bf04ede3ce6e Subject: Re: [9fans] 9front pegs CPU on VMware Topicbox-Message-UUID: a0b614f4-ead8-11e9-9d60-3106f5b1d025 --047d7bd770228af1bf04ede3ce6e Content-Type: text/plain; charset=ISO-8859-1 > > > 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. --047d7bd770228af1bf04ede3ce6e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Latency is worse than using mwait because you are sleeping unconditionally.=
Mwait does not prevent you from getting the interrupt to schedule.

<= /blockquote>

By this I mean that mwait unblocks on inter= rupt. =A0You 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:

wh= ile(1){
=A0 =A0 =A0 mwait(&l->mwaitvar);
=A0 =A0= =A0 test_the_var_and break();
=A0 =A0 =A0 sleep(0); //one out of= N iterations
}

This will make the the process consume a li= ttle part of the quantum (until the next tick) =A0waiting, and most
of that time the processor is turned off or at least consuming less.

G.

--047d7bd770228af1bf04ede3ce6e--