Boost logo

Boost Users :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2008-04-30 15:52:40


Axel wrote:
> Hello,
>
> In a single process but multithreaded software, should I use
> Boost.Threads synchronization mechanisms or can I use Boost.Interprocess
> synchronization mechanisms without counterparts and without seeing any
> difference ? ( in particular boost::interprocess::interprocess_semaphore
> class )

In theory, you could use Boost.Interprocess, but those are prepared for
shared memory and not optimized for a single process inter-thread
synchronization. I would recommend using Boost.Thread.

> When using interprocess_mutex, my programm threw a lock_exception. I
> changed to boost::mutex and didn't managed to reproduce it. So, could
> this be related or the lock_exception has same chances to happen with
> boost::mutex ?

I don't know, you could use catch that exception and print what it says.

> I'm using semaphore to synchronize threads, so is it reliable in a
> single process multithreaded software ?

It should be, but I think a more efficient semaphore could be built for
Boost.Thread. I know some consider semaphores risky, but for many tasks
(like drivers, or signals) it's the only mechanism allowed by the OS to
notify events to other threads.

Regards,

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