Boost logo

Boost :

From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2003-02-25 11:34:57


"William E. Kempf" wrote:
[...]
> > explicit scoped_lock(lightweight_mutex & m): m_(m)
> > {
> > while( InterlockedExchange(&m_.l_, 1) )
> > {
> > // Note: changed to Sleep(1) from Sleep(0).
> > // According to MSDN, Sleep(0) will never yield
> > // to a lower-priority thread, whereas Sleep(1)
> > // will. Performance seems not to be affected.
> >
> > Sleep(1);
> > }
> > }
> >
> > (I don't actually use yield yet, so currently have no preference for
> > either, but just wondered what the intended use of yield was)
                                       ^^^^^^^^^^^^^^^^^^^^^

Well, <quoting Butenhof> "sched_yield() can be used to resolve some problems
on a uniprocessor, though such problems can usually be solved more cleanly in
other ways. Using sched_yield() will never solve a problem (unless the problem
statement is "the performance is too good") on a multiprocessor, and you
should never use it there."

http://groups.google.com/groups?selm=LiSt9.14%24jw2.278613%40news.cpqcorp.net
(Subject: Re: relinquishing a time-slice)

http://groups.google.com/groups?selm=rzdE7.1198%24RL6.17634%40news.cpqcorp.net
(Subject: Re: Thread yield question (repost))

>
> I'll look into this and fix it. Thanks.

Other than "breaking" the yield() it won't fix anything, I'm afraid.

regards,
alexander.

--
It's "Unix" if it has the "x" sound in its name - the Xbox must be Unix then.
                                         --from a discussion on slashdot.org

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