mutex problems on Windows
- From: Dov Grobgeld <dov grobgeld gmail com>
- To: Gnome List <gtk-list gnome org>
- Subject: mutex problems on Windows
- Date: Mon, 6 Jul 2009 17:13:07 +0300
I'm having a problem with GMutex under Windows that don't lock. The behaviour is definitely different from that under Linux.
The system is composed of to threads. A gui thread G and a worker thread W. The ping pong between the threads via a mutex j->M should work as follows. j is a job data structure that carries info between the worker thread and the gui thread.
- W locks j->M through g_mutex_lock(j->M) so that a subsequent lock will block.
- W fills in j with various info to display.
- W calls g_idle_add(GSourceFunc(cb_update_job), j) to indicate to G that there is info to display.
- W blocks on M through a second call to g_mutex_lock(j->M)
- G is called in cb_update_job() and updates the gui, also possibly updates j, and then does g_mutex_unlock(j->M)
- W wakes up and does a g_mutex_unlock(j->M) as it no longer needs the lock on the mutex.
- W examines the return info that G filled in into j and contiues or aborts its operation.
The problem on Win32 is that g_mutex_lock in 4 doesn't block and the thread continues, which eventually will cause the system to crash.
Is something supposed to be different under Windows, or should I file a bug?
Thanks!
Dov
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]