Re: bug in thread-test.c
- From: Miroslaw Dobrzanski-Neumann <mne mosaic-ag com>
- To: GTKDEV <gtk-devel-list gnome org>
- Subject: Re: bug in thread-test.c
- Date: Tue, 12 Feb 2002 15:17:12 +0100
Hi Sebastian,
the next bug
line 61 fails
if the test_g_static_rec_mutex_thread starts immediately and is not interrupted, than test_g_static_rec_mutex_int is still 0 as set in line 49.
you should test_g_static_rec_mutex_mutex = 42 before call to g_thread_create()
49 static guint test_g_static_rec_mutex_int = 0;
50 static gboolean test_g_static_rec_mutex_thread_ready;
51
52 static gpointer
53 test_g_static_rec_mutex_thread (gpointer data)
54 {
55 g_assert (GPOINTER_TO_INT (data) == 42);
56 g_assert (g_static_rec_mutex_trylock (&test_g_static_rec_mutex_mutex)
57 == FALSE);
58 test_g_static_rec_mutex_thread_ready = TRUE;
59 g_static_rec_mutex_lock (&test_g_static_rec_mutex_mutex);
60 g_static_rec_mutex_lock (&test_g_static_rec_mutex_mutex);
61 g_assert (test_g_static_rec_mutex_int == 42);
62 g_static_rec_mutex_unlock (&test_g_static_rec_mutex_mutex);
63 g_static_rec_mutex_unlock (&test_g_static_rec_mutex_mutex);
64
65 g_thread_exit (GINT_TO_POINTER (43));
66
67 g_assert_not_reached ();
68 return NULL;
69 }
70
71 static void
72 test_g_static_rec_mutex (void)
73 {
74 GThread *thread;
75
76 g_assert (g_static_rec_mutex_trylock (&test_g_static_rec_mutex_mutex));
77 test_g_static_rec_mutex_thread_ready = FALSE;
78 thread = g_thread_create (test_g_static_rec_mutex_thread,
79 GINT_TO_POINTER (42), TRUE, NULL);
80 /* This busy wait is only for testing purposes and not an example of
81 * good code!*/
82 while (!test_g_static_rec_mutex_thread_ready)
83 g_usleep (G_USEC_PER_SEC / 5);
84
bye
--
Miroslaw Dobrzanski-Neumann
MOSAIC SOFTWARE AG
Base Development and Research
Tel +49-2225-882-291
Fax +49-2225-882-201
E-mail: mne mosaic-ag com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]