Re: [AD] race condition when removing/adding ints |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Wed, 2005-01-26 at 08:23 +0100, Eric Botcazou wrote:
> > Anyone remember what this line in timer.c means:
> >
> > #undef ALLEGRO_MULTITHREADED /* FIXME */
>
> I added it because we had deadlocks in the X11 port without it.
>
> The problem with the timer.c code in a multithreaded environment is that you
> can remove a timer while the callback is being invoked (e.g. in the mouse
> pointer case). Hence we need a global mutex. But IIRC this didn't play nice
> with the original X11 code.
>
If the problem was only X11, that's good, then with the attached patch
it should work. The only deadlock I found was due to adding/removing the
key repeat timer while the X11 lock was held - but I don't think there's
another place where this happens.
The first patch simply removes that #define (for all platforms).
The second removes the keyboard timer from the X11 keyboard driver, and
ideally the same would be done with all ports (even DOS does without
it!). But it seems, DOS and X11 have the advantage to get the key repeat
from the HW/the OS - while DirectX discards that information for us.
Again, would need a windows/DX expert to know how to get key repeat
info. Maybe using winapi functions to get keys instead? In any case,
with these two patches, the X11 port works smoothly for me (32bit), no
deadlocks so far - and the testcase from allegro.cc works fine now.
[and yes, both patches are one-liners :P]
--
Elias Pschernig
Index: src/timer.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/timer.c,v
retrieving revision 1.17
diff -p -u -r1.17 timer.c
--- src/timer.c 22 Aug 2004 01:57:14 -0000 1.17
+++ src/timer.c 26 Jan 2005 10:55:00 -0000
@@ -23,9 +23,6 @@
#include "allegro.h"
#include "allegro/internal/aintern.h"
-#undef ALLEGRO_MULTITHREADED /* FIXME */
-
-
TIMER_DRIVER *timer_driver = NULL; /* the active driver */
int _timer_installed = FALSE;
Index: src/x/xkeyboard.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xkeyboard.c,v
retrieving revision 1.9
diff -u -p -r1.9 xkeyboard.c
--- src/x/xkeyboard.c 10 Dec 2004 14:37:55 -0000 1.9
+++ src/x/xkeyboard.c 26 Jan 2005 11:11:40 -0000
@@ -785,7 +785,7 @@ static KEYBOARD_DRIVER keyboard_x =
"X11 keyboard",
"X11 keyboard",
"X11 keyboard",
- TRUE,
+ FALSE,
x_keyboard_init,
x_keyboard_exit,
NULL, // AL_METHOD(void, poll, (void));