pthread_mutexattr_init problem
Joost Kraaijeveld
J.Kraaijeveld@Askesis.nl
Fri Oct 17 01:24:00 GMT 2003
Hi all,
Can anyone explain to me under what circumstances pthread_mutexattr_init
returns EBUSY? I read the explanations in
http://sources.redhat.com/ml/cygwin/2003-06/msg00431.html and
http://www.opengroup.org/onlinepubs/007904975/functions/pthread_mutexatt
r_init.html and from that I understand that pthread_mutexattr_init
returns EBUSY if one tries to initialize twice. However I get the error
in the following part of code (see below & the arrows on the left). The
initialization is done only once.
Note:
If I initialize pthread_mutexattr_t m_attr with 0 (because it's actually
a pointer to a struct according to <sys/types>) the code runs OK. This
looks strange to me. Why should I have to initialize a
pthread_mutexattr_t by any other means than by calling
pthread_mutexattr_init ?
MICOMT::Mutex::Mutex(MICO_Boolean locked, Attribute attr)
{
int result;
pthread_mutexattr_t m_attr /* = 0 */; <-----
--> result = pthread_mutexattr_init(&m_attr);
--> assert(!result);
if (attr != Normal) {
switch (attr) {
case Recursive:
result =
pthread_mutexattr_settype(&m_attr,PTHREAD_MUTEX_RECURSIVE);
assert (!result);
break;
default:
break;
}
}
result = pthread_mutex_init(&_mutex, &m_attr);
assert(!result);
result = pthread_mutexattr_destroy(&m_attr);
assert(!result);
if (locked)
this->lock();
}
TIA
Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
email: J.Kraaijeveld@Askesis.nl
web: www.askesis.nl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2226 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20031017/56de4965/attachment.bin>
More information about the Cygwin
mailing list