From: Konstantin Voronkov <beowinkle@yahoo.com>
To: pthreads-win32@sources.redhat.com
Subject: Problem with recursive mutex : pthread_mutex_unlock() returns EPERM code
Date: Thu, 30 Dec 2004 15:27:00 -0000 [thread overview]
Message-ID: <20041230152716.42907.qmail@web13523.mail.yahoo.com> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 1934 bytes --]
Hello All!
I have problem with recursive mutex.
pthread_mutex_unlock()
returns 1 EPERM code. I do not understan what I'm
doing wrong,
can you help me, please?
I'm using pthread-win32 snapshot 2004-11-22 pre-build
library. The library taken from here:
http://sources.redhat.com/pthreads-win32/
I managed to reproduce problem in simple test
application.
Abort happens here after some time of work of this
program:
#include <pthread.h>
#include <windows.h>
class MutexWrapper
{
public:
// mutex initialization
MutexWrapper()
: m_reg_mutex(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
{
}
// mutex freeing
~MutexWrapper()
{
pthread_mutex_destroy(&m_reg_mutex);
}
// locks the mutex
void Lock()
{
pthread_mutex_lock(&m_reg_mutex);
}
void UnLock()
{
const int retCode =
pthread_mutex_unlock(&m_reg_mutex);
if(retCode)
// abort happens here after
some time of work of program
abort();
}
private:
pthread_mutex_t m_reg_mutex; // mutex object
member
};
unsigned long WINAPI threadFunc(void *mux)
{
while(true)
{
reinterpret_cast<MutexWrapper *>(mux)->Lock();
reinterpret_cast<MutexWrapper *>(mux)->UnLock();
}
return 0;
}
int main(int argc, char* argv[])
{
MutexWrapper mux;
CreateThread(0, 0, threadFunc, &mux, 0, 0);
while(true)
{
mux.Lock();
mux.UnLock();
}
return 0;
}
================
the project settings of test application:
linker options: pthreadVC1.lib /nologo
/subsystem:console /incremental:no
/pdb:"Release/CsuByteArrayTest.pdb" /machine:I386
compiler options: /nologo /MD /W3 /GX /O2 /D "WIN32"
/D "NDEBUG" /D "_CONSOLE"
/D "_MBCS" /Fo"Release/" /Fd"Release/" /FD /c
problem reproduces with MSVC 6.0 sp5 compiler
problem reproduces on WinXP sp2, and on Windows 2000
sp4
Best Regards,
Voronkov Konstantin
__________________________________
Do you Yahoo!?
All your favorites on one personal page Try My Yahoo!
http://my.yahoo.com
next reply other threads:[~2004-12-30 15:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-30 15:27 Konstantin Voronkov [this message]
2005-01-01 1:15 ` Ross Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041230152716.42907.qmail@web13523.mail.yahoo.com \
--to=beowinkle@yahoo.com \
--cc=pthreads-win32@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).