Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Changeing to recursive critical sections... (?)
Changeing to recursive critical sections... (?) [message #8449] Sat, 10 March 2007 13:59 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I have wasted 4 days finding a bug that ended as another Linux mutex deadlock case. To explain, default Linux version of mutex (unlike Win32 critical section) does not allow single thread to lock the same mutex twice. This often leads to quite tiresome problems and hard to spot bugs.

Now I have found there exists "PTHREAD_MUTEX_RECURSIVE" (non-default) attribute that should avoid this trouble. Anyway, support on various platforms does not seem to be consistent, at least it was not in the past.

Therefore, before going there, any information about platform specific issues is highly appreciated.

Mirek
Re: Changeing to recursive critical sections... (?) [message #8452 is a reply to message #8449] Sat, 10 March 2007 21:20 Go to previous message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
As expected, it is also defined on FreeBSD in pthread header:

/*
 * Mutex types (Single UNIX Specification, Version 2, 1997).
 *
 * Note that a mutex attribute with one of the following types:
 *
 *      PTHREAD_MUTEX_NORMAL
 *      PTHREAD_MUTEX_RECURSIVE
 *      MUTEX_TYPE_FAST (deprecated)
 *      MUTEX_TYPE_COUNTING_FAST (deprecated)
 *
 * will deviate from POSIX specified semantics.
 */
enum pthread_mutextype {
        PTHREAD_MUTEX_ERRORCHECK        = 1,    /* Default POSIX mutex */
        PTHREAD_MUTEX_RECURSIVE         = 2,    /* Recursive mutex */
        PTHREAD_MUTEX_NORMAL            = 3,    /* No error checking */
        MUTEX_TYPE_MAX
};

#define PTHREAD_MUTEX_DEFAULT           PTHREAD_MUTEX_ERRORCHECK
#define MUTEX_TYPE_FAST                 PTHREAD_MUTEX_NORMAL
#define MUTEX_TYPE_COUNTING_FAST        PTHREAD_MUTEX_RECURSIVE

Matthias
Previous Topic: New Core preview
Next Topic: pkg-config discussion
Goto Forum:
  


Current Time: Fri Mar 29 14:51:13 CET 2024

Total time taken to generate the page: 0.02258 seconds