Home > pthread mutex destroy error > pthread_mutex_destroy error codes

Pthread_mutex_destroy Error Codes

Contents

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of

Pthread_mutex_destroy Example

this site About Us Learn more about Stack Overflow the company Business Learn pthread_mutex_destroy ebusy more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question

Pthread_mutex_destroy Error 16

x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up pthread_mutex_destroy necessary How to handle error conditions of pthread_mutex_destroy up vote 1 down vote favorite When I try to destroy mutex via pthread_mutex_destroy(&mutex), it intermittently fails. I am doing an assert if the pthread_mutex_destroy fails. But do we have a better option compared to assert (apart from raising exception)? EDIT: void cleanUp() { int rval=0; rval = pthread_cond_destroy(&m_Condition); assert(rval == 0); rval = pthread_mutex_destroy(&m_Mutex); assert(rval pthread mutex example == 0); rval = pthread_mutexattr_destroy(&m_Attr); assert(rval == 0); } EDIT 2: void semaphoreVMware::semaphoreVMware() { int rval = 0; rval = pthread_mutexattr_init(&m_Attr); assert(rval == 0); rval = pthread_mutexattr_settype(&m_Attr, PTHREAD_MUTEX_RECURSIVE); assert(rval == 0); rval = pthread_mutex_init(&m_Mutex, &m_Attr); assert(rval == 0); rval = pthread_cond_init(&m_Condition, NULL); assert(rval == 0); } EDIT 3:Declaration of the mutex: env::Mutex m_Mutex; c unix pthreads mutex share|improve this question edited Dec 10 '13 at 13:49 alk 45.1k53497 asked Dec 10 '13 at 6:34 Ravikanth 357 do you know why it is failing? –Glenn Teitelbaum Dec 10 '13 at 6:36 Can you please post some sample code? Can't you check the return value and take an action instead of throwing an assert? –ServerMonkey Dec 10 '13 at 6:37 @ServerMonkey almost all of the errors from pthread_mutex_destroy are programming errors, with the exception of resource limitation, which should not be intermittent. It would be better to fix the problems so that the errors do not occur. –Glenn Teitelbaum Dec 10 '13 at 6:41 Hello,Thanks for your reply.Actually the cleanup code which i have posted gets called whenever we stop our s

Programmer's ManualPTHREAD_MUTEX_DESTROY(3P) PROLOG top This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME top pthread_mutex_destroy, pthread_mutex_init — destroy and initialize a mutex SYNOPSIS top #include int pthread_mutex_destroy(pthread_mutex_t *mutex); int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr); pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; DESCRIPTION top The pthread_mutex_destroy() function shall destroy the mutex object referenced by mutex; the mutex object becomes, in effect, uninitialized. An implementation may cause pthread_mutex_destroy() to set the object referenced by mutex to an invalid value. A destroyed mutex object can be reinitialized using pthread_mutex_init(); the results of otherwise referencing the object after it has been destroyed are undefined. It shall be safe to destroy an initialized mutex that is unlocked. Attempting to destroy a locked mutex or a mutex that is referenced (for example, while being used in a pthread_cond_timedwait() or pthread_cond_wait()) by another thread results in undefined behavior. The pthread_mutex_init() function shall initialize the mutex referenced by mutex with attributes specified by attr. If attr is NULL, the default mutex attributes are used; the effect shall be the same as passing the address of a default mutex attributes object. Upon successful initialization, the state of the mutex becomes initialized and unlocked. Only mutex itself may be used for performing synchronization. The result of referring to copies of mutex in calls to pthread_mutex_lock(), pthread_mutex_trylock(), pthread_mutex_unlock(), and pthread_mutex_destroy() is undefined. Attempting to initialize an already initialized mutex results in undefined behavior. In cases where default mutex attributes are appropriate, the macro PTHREAD_MUTEX_INITIALIZER can be used to initialize mutexes. The effect shall be equivalent to dynamic initialization by a call to pthread_mutex_init() with parameter attr specified as NULL, except that no error checks are performed. The behavior is undefined if the value specified by

 

Related content

pthread_mutex_destroy error

Pthread mutex destroy Error table id toc tbody tr td div id toctitle Contents div ul li a href Pthread mutex destroy Ebusy a li li a href Pthread cond destroy a li li a href Pthread mutex init Example In C a li ul td tr tbody table p destroy and relatedl initialize a mutex SYNOPSIS tt sup a href javascript open code 'THR' THR a sup pthread mutex destroy example img src images opt-start gif alt Option Start border include a p h id Pthread mutex destroy Ebusy p href basedefs pthread h html pthread h a br

pthread_mutex_destroy error 16

Pthread mutex destroy Error table id toc tbody tr td div id toctitle Contents div ul li a href Pthread mutex destroy Ebusy a li li a href Pthread cond destroy a li li a href Pthread mutex t Struct a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta relatedl Discuss the workings and policies of this site About pthread mutex destroy example Us Learn more about Stack Overflow the company Business Learn more about hiring p h id Pthread mutex destroy

pthread_mutex_destroy error code 16

Pthread mutex destroy Error Code table id toc tbody tr td div id toctitle Contents div ul li a href Pthread cond destroy a li li a href Pthread Mutex Example a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings relatedl and policies of this site About Us Learn more about pthread mutex destroy example Stack Overflow the company Business Learn more about hiring developers or posting ads with pthread mutex destroy ebusy us Stack Overflow Questions Jobs Documentation