recursive mutex?

Michael VanLoon MichaelV@EDIFECS.COM
Wed Oct 17 18:27:00 GMT 2001


It's funny because I just came across this with Forte C++ on Solaris.  It
seems Solaris 2.8 and 2.7 pthreads implementation have an option for
recursive on the pthreads mutex, but Solaris 2.6 (and older I assume) does
not.

Is this system-specific?  And/or maybe something introduced in a recent
revision of pthreads that wasn't in earlier versions?

If you write a wrapper class, it's trivial to make your wrapper recursive
and have it call the underlying mutex non-recursively.  (And I wouldn't
program without a wrapper in a C++ paradigm anyway, since the C-style
threading methods don't facilitate automatic construction/destruction.)

For what it's worth, here's the function call to set the pthread mutex to
recursive on Solaris 2.8:

int iRet = pthread_mutex_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);

> -----Original Message-----
> From: Carlo Wood [ mailto:carlo@alinoe.com ]
> Sent: Wednesday, October 17, 2001 6:12 PM
> To: libstdc++@gcc.gnu.org
> Subject: recursive mutex?
> 
> 
> I need a recursive mutex lock, but it seems the STL/libstdc++ doesn't
> already have one.  Or do I miss something?
> 
> -- 
> Carlo Wood <carlo@alinoe.com>
> 



More information about the Libstdc++ mailing list