Boost logo

Boost :

Subject: Re: [boost] [Boost.Interprocess] conditions variables get 10 times faster when opening a multiprocess browser
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2013-09-08 01:39:51


I haven't looked at the code, but I see mention of Sleep(0) here. Does
everyone realize the special behavior of Sleep(0) ?

It only gives up a timeslice to threads of >= priority. Starving lower
priority threads (if you were to spin with only that).

Not sure it is a problem inthis case, but wanted to mention it, as it is
often overlooked.

Tony

Sent from my portable Analytical Engine

------------------------------
*From:* "Ion Gaztañaga" <igaztanaga_at_[hidden]>
*To:* "boost_at_[hidden]" <boost_at_[hidden]>
*Sent:* 21 August, 2013 4:42 PM
*Subject:* Re: [boost] [Boost.Interprocess] conditions variables get 10
times faster when opening a multiprocess browser

El 21/08/2013 17:43, Peter Dimov escribió:

> But the timeslice is not necessarily 20ms. A call to timeBeginPeriod(1)
> may shorten it.

timeBeginPeriod seems a bit scary as it affects the general windows
scheduler. One option could be to call GetTickCount until it changes its
value twice (as the resolution of this time is the resolution of the
system timer). Once it changes (after 20-40ms looping, on average that
would me 30ms), then Sleep(1) is called. And for uniprocessor systems we
should avoid doing any loop and call only Sleep(0). But that would be a
really hard to implement spinlock ;-)

Another option is to obtain the a high resolution timestamp each loop
and just loop, say, for 100ms before going to Sleep(1).

Best,

Ion

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk