Boost logo

Boost Users :

Subject: Re: [Boost-users] [interprocess] (OS X) waiting on condition variable = CPU 100% + fans running loud
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2013-01-06 07:53:08


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net