but I need that a function owns it the first time and when this function has done its work, release the mutex and the main function (where the mutex was created)can take it
I have to threads: one in the main function, one in a separate function
I have a global mutex who is created in the main function (mutex_req=CreateMutex(NULL, FALSE, "my_mutex") the second parameter set to FALSE means that the main thread doesn't take it after creating.
So the second thread takes it and works, at the end, releases it and then the main function thread should take it and works but it does'n work. The main thread stays at this point in the WaitForSingleObject(mutex_req)
int main()
{
thread2 = CreateThread(0, 0,(LPTHREAD_START_ROUTINE) tcpserver,NULL,0,&threadID2);
....
WaitForSingleObject(mutex_req,INFINITE);//when first dump ready, we request the next
length = createMessage2(packet);
initiateRxDump(packet);
ReleaseMutex(mutex_req);
......
}