Boost logo

Boost :

Subject: Re: [boost] [interprocess] (OS X) waiting on condition variable = CPU 100% + fans running loud
From: Francisco Lopes (francisco.mailing.lists_at_[hidden])
Date: 2013-01-06 10:26:15


>
> El 05/01/2013 17:34, Francisco Lopes escribió:
> > Hi, I was implementing a kind of server using shared memory.
> > The server should keep idle, waiting for a request and I do this by
> > waiting on a condition
> > variable, of course.
> >
> > I then noticed my fans running high when I let the server waiting a
> > little longer while testing
> > and discovered this happens simply because of some busy loop
> > implementation for condition
> > waiting.
> >
> > Is there any reason for that? Given the interprocess library age, no
> > way for implementing a
> > non-busy interprocess condition variable waiting is available?
>
> MacOS does not support POSIX process-shared synchronization primitives and
> it's pretty hard to emulate them without kernel help (I think it's the only
> "major" modern UNIX OS without that support). I haven't found any library
> that tries to emulate them on MacOs to get some ideas about the emulation.
> We have a similar problem in Windows, and there is a very early emulation
> that avoids spinning but it's still too buggy to be the default. Sadly this
> emulation idea does not work with MacOs due to differences in named
> synchronization mechanism lifetimes between windows and mac operating
> systems.
> It's maybe the biggest problem we have with Interprocess, sorry about
> that. Maybe you can avoid 100% CPU usage inserting sleeps between atomic
> operation tries in interprocess_mutex or interprocess_condition code. Sorry
> about the bad news.
> Ion

Eesponded by the library mantainer on boost-users, sad.

2013/1/6 Tim Blechmann <tim_at_[hidden]>

> hi,
>
> > Hi, I was implementing a kind of server using shared memory.
> > The server should keep idle, waiting for a request and I do this by
> > waiting on a condition variable, of course.
> >
> > I then noticed my fans running high when I let the server waiting a
> > little longer while testing and discovered this happens simply because
> > of some busy loop implementation for condition waiting.
> >
> > Is there any reason for that?
> >
> > Given the interprocess library age, there's no way for implementing a
> > non-busy interprocess condition variable waiting available?
>
> not sure if it is related, but it somehow reminds me of an issue that
> unnamed semaphores are not implemented on osx ... compare [1]
>
> tim
>
> [1] http://heldercorreia.com/blog/semaphores-in-mac-os-x
>


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