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