I try to initialize a mutex (VS 2008/windows xp sp2), but each time I run my app, the line:
pthread_mutex_init(&mutex, NULL);
gives me the following error:
0xC0000096: Privileged instruction.
I declare my mutex with:
static pthread_mutex_t mutex;
I tried to not call pthread_mutex_init declaring my mutex like:
static pthread_mutex_t mutex= PTHREAD_MUTEX_INITIALIZER;
but
pthread_mutex_lock(&mutex);
crash with the 0xC0000096: Privileged instruction error.
What am I doing wrong ?
On Windows, you must use the
CreateMutexAPI to initialize a mutex object.Or you can use the new C++
mutexclass, provided your compiler supports it.