From: Tim Janik Date: Mon, 1 Aug 2005 21:47:15 +0000 (+0000) Subject: test high contention on closure reference counts to trigger and catch X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=10a3867a6e88c5980e04c6a5623e1f0ae89f7116;p=dana%2Fcg-glib.git test high contention on closure reference counts to trigger and catch Mon Aug 1 23:33:47 2005 Tim Janik * tests/refcount/closures.c: test high contention on closure reference counts to trigger and catch non-atomic updates. * tests/refcount/objects.c: * tests/refcount/objects2.c: * tests/refcount/properties.c: * tests/refcount/properties2.c: * tests/refcount/signals.c: fixed up test and threading fundamentals. variables accessed from all threads need to be volatile. context switches are enforced by using g_thread_yield(), not g_usleep(1) which may result in busy waits on some platforms. for testcode, always consider all warnings and critical messages fatal. issue the currently running program on stdout. improved progress indicators. * tests/refcount/properties.c: * tests/refcount/objects.c: don't overdo the number of testing threads to keep the testing machine usable, 2 threads can produce as much contention as 20 if executing the same code. * tests/refcount/signals.c: only start 1 thread per object. GObject doesn't provide mutually exclusive object access, but only mutually exclusive reference count modification. * tests/Makefile.am: added closures test. --- diff --git a/ChangeLog b/ChangeLog index 7044e027..438bb554 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +Mon Aug 1 23:33:47 2005 Tim Janik + + * tests/refcount/closures.c: test high contention on closure + reference counts to trigger and catch non-atomic updates. + + * tests/refcount/objects.c: + * tests/refcount/objects2.c: + * tests/refcount/properties.c: + * tests/refcount/properties2.c: + * tests/refcount/signals.c: + fixed up test and threading fundamentals. variables accessed from all + threads need to be volatile. context switches are enforced by using + g_thread_yield(), not g_usleep(1) which may result in busy waits on + some platforms. for testcode, always consider all warnings and + critical messages fatal. issue the currently running program on + stdout. improved progress indicators. + + * tests/refcount/properties.c: + * tests/refcount/objects.c: + don't overdo the number of testing threads to keep the testing machine + usable, 2 threads can produce as much contention as 20 if executing the + same code. + + * tests/refcount/signals.c: only start 1 thread per object. GObject + doesn't provide mutually exclusive object access, but only mutually + exclusive reference count modification. + + * tests/Makefile.am: added closures test. + 2005-08-01 Tor Lillqvist * tests/uri-test.c: Make it pass on Win32. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7044e027..438bb554 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,32 @@ +Mon Aug 1 23:33:47 2005 Tim Janik + + * tests/refcount/closures.c: test high contention on closure + reference counts to trigger and catch non-atomic updates. + + * tests/refcount/objects.c: + * tests/refcount/objects2.c: + * tests/refcount/properties.c: + * tests/refcount/properties2.c: + * tests/refcount/signals.c: + fixed up test and threading fundamentals. variables accessed from all + threads need to be volatile. context switches are enforced by using + g_thread_yield(), not g_usleep(1) which may result in busy waits on + some platforms. for testcode, always consider all warnings and + critical messages fatal. issue the currently running program on + stdout. improved progress indicators. + + * tests/refcount/properties.c: + * tests/refcount/objects.c: + don't overdo the number of testing threads to keep the testing machine + usable, 2 threads can produce as much contention as 20 if executing the + same code. + + * tests/refcount/signals.c: only start 1 thread per object. GObject + doesn't provide mutually exclusive object access, but only mutually + exclusive reference count modification. + + * tests/Makefile.am: added closures test. + 2005-08-01 Tor Lillqvist * tests/uri-test.c: Make it pass on Win32. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 7044e027..438bb554 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,32 @@ +Mon Aug 1 23:33:47 2005 Tim Janik + + * tests/refcount/closures.c: test high contention on closure + reference counts to trigger and catch non-atomic updates. + + * tests/refcount/objects.c: + * tests/refcount/objects2.c: + * tests/refcount/properties.c: + * tests/refcount/properties2.c: + * tests/refcount/signals.c: + fixed up test and threading fundamentals. variables accessed from all + threads need to be volatile. context switches are enforced by using + g_thread_yield(), not g_usleep(1) which may result in busy waits on + some platforms. for testcode, always consider all warnings and + critical messages fatal. issue the currently running program on + stdout. improved progress indicators. + + * tests/refcount/properties.c: + * tests/refcount/objects.c: + don't overdo the number of testing threads to keep the testing machine + usable, 2 threads can produce as much contention as 20 if executing the + same code. + + * tests/refcount/signals.c: only start 1 thread per object. GObject + doesn't provide mutually exclusive object access, but only mutually + exclusive reference count modification. + + * tests/Makefile.am: added closures test. + 2005-08-01 Tor Lillqvist * tests/uri-test.c: Make it pass on Win32. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 7044e027..438bb554 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,32 @@ +Mon Aug 1 23:33:47 2005 Tim Janik + + * tests/refcount/closures.c: test high contention on closure + reference counts to trigger and catch non-atomic updates. + + * tests/refcount/objects.c: + * tests/refcount/objects2.c: + * tests/refcount/properties.c: + * tests/refcount/properties2.c: + * tests/refcount/signals.c: + fixed up test and threading fundamentals. variables accessed from all + threads need to be volatile. context switches are enforced by using + g_thread_yield(), not g_usleep(1) which may result in busy waits on + some platforms. for testcode, always consider all warnings and + critical messages fatal. issue the currently running program on + stdout. improved progress indicators. + + * tests/refcount/properties.c: + * tests/refcount/objects.c: + don't overdo the number of testing threads to keep the testing machine + usable, 2 threads can produce as much contention as 20 if executing the + same code. + + * tests/refcount/signals.c: only start 1 thread per object. GObject + doesn't provide mutually exclusive object access, but only mutually + exclusive reference count modification. + + * tests/Makefile.am: added closures test. + 2005-08-01 Tor Lillqvist * tests/uri-test.c: Make it pass on Win32. diff --git a/tests/refcount/Makefile.am b/tests/refcount/Makefile.am index 5d98c326..67139f2a 100644 --- a/tests/refcount/Makefile.am +++ b/tests/refcount/Makefile.am @@ -11,14 +11,17 @@ libgobject = $(top_builddir)/gobject/libgobject-2.0.la LDADD = $(libgobject) $(libgthread) -test_programs = \ - signal1 \ - signal2 \ - signal3 \ +test_programs = \ + closures \ objects \ objects2 \ properties \ - properties2 + properties2 \ + signal1 \ + signal2 \ + signal3 + + signal1_SOURCES = signals.c signal1_CFLAGS = -DTESTNUM=1 $(AM_CFLAGS) @@ -29,6 +32,8 @@ signal3_CFLAGS = -DTESTNUM=3 $(AM_CFLAGS) check_PROGRAMS = $(test_programs) +all: $(check_PROGRAMS) + TESTS = $(test_programs) TESTS_ENVIRONMENT = srcdir=$(srcdir) \ LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset diff --git a/tests/refcount/closures.c b/tests/refcount/closures.c new file mode 100644 index 00000000..65084451 --- /dev/null +++ b/tests/refcount/closures.c @@ -0,0 +1,292 @@ +/* Copyright (C) 2005 Imendio AB + * + * This software is provided "as is"; redistribution and modification + * is permitted, provided that the following disclaimer is retained. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * In no event shall the authors or contributors be liable for any + * direct, indirect, incidental, special, exemplary, or consequential + * damages (including, but not limited to, procurement of substitute + * goods or services; loss of use, data, or profits; or business + * interruption) however caused and on any theory of liability, whether + * in contract, strict liability, or tort (including negligence or + * otherwise) arising in any way out of the use of this software, even + * if advised of the possibility of such damage. + */ +#include +#include + +#define TEST_POINTER1 ((gpointer) 47) +#define TEST_POINTER2 ((gpointer) 49) +#define TEST_INT1 (-77) +#define TEST_INT2 (78) + +/* --- GTest class --- */ +typedef struct { + GObject object; + gint value; + gpointer test_pointer1; + gpointer test_pointer2; +} GTest; +typedef struct { + GObjectClass parent_class; + void (*test_signal1) (GTest * test, gint an_int); + void (*test_signal2) (GTest * test, gint an_int); +} GTestClass; + +#define G_TYPE_TEST (g_test_get_type ()) +#define G_TEST(test) (G_TYPE_CHECK_INSTANCE_CAST ((test), G_TYPE_TEST, GTest)) +#define G_IS_TEST(test) (G_TYPE_CHECK_INSTANCE_TYPE ((test), G_TYPE_TEST)) +#define G_TEST_CLASS(tclass) (G_TYPE_CHECK_CLASS_CAST ((tclass), G_TYPE_TEST, GTestClass)) +#define G_IS_TEST_CLASS(tclass) (G_TYPE_CHECK_CLASS_TYPE ((tclass), G_TYPE_TEST)) +#define G_TEST_GET_CLASS(test) (G_TYPE_INSTANCE_GET_CLASS ((test), G_TYPE_TEST, GTestClass)) + +G_DEFINE_TYPE (GTest, g_test, G_TYPE_OBJECT); + +/* --- variables --- */ +static volatile gboolean stopping = FALSE; +static guint test_signal1 = 0; +static guint test_signal2 = 0; +static gboolean seen_signal_handler = FALSE; +static gboolean seen_cleanup = FALSE; +static gboolean seen_test_int1 = FALSE; +static gboolean seen_test_int2 = FALSE; +static gboolean seen_thread1 = FALSE; +static gboolean seen_thread2 = FALSE; + +/* --- functions --- */ +static void +g_test_init (GTest * test) +{ + g_print ("init %p\n", test); + + test->value = 0; + test->test_pointer1 = TEST_POINTER1; + test->test_pointer2 = TEST_POINTER2; +} + +enum { + ARG_0, + ARG_TEST_PROP +}; + +static void +g_test_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GTest *test = G_TEST (object); + switch (prop_id) + { + case ARG_TEST_PROP: + test->value = g_value_get_int (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +g_test_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GTest *test = G_TEST (object); + switch (prop_id) + { + case ARG_TEST_PROP: + g_value_set_int (value, test->value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +g_test_test_signal2 (GTest *test, + gint an_int) +{ +} + +static void +g_test_emit_test_signal1 (GTest *test, + gint vint) +{ + g_signal_emit (G_OBJECT (test), test_signal1, 0, vint); +} + +static void +g_test_emit_test_signal2 (GTest *test, + gint vint) +{ + g_signal_emit (G_OBJECT (test), test_signal2, 0, vint); +} + +static void +g_test_class_init (GTestClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->set_property = g_test_set_property; + gobject_class->get_property = g_test_get_property; + + test_signal1 = g_signal_new ("test-signal1", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GTestClass, test_signal1), NULL, NULL, + g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); + test_signal2 = g_signal_new ("test-signal2", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GTestClass, test_signal2), NULL, NULL, + g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TEST_PROP, + g_param_spec_int ("test-prop", "Test Prop", "Test property", + 0, 1, 0, G_PARAM_READWRITE)); + klass->test_signal2 = g_test_test_signal2; +} + +static inline guint32 +quick_rand32 (void) +{ + static guint32 accu = 2147483563; + accu = 1664525 * accu + 1013904223; + return accu; +} + +static void +test_closure (GClosure *closure) +{ + /* try to produce high contention in closure->ref_count */ + guint i = 0, n = quick_rand32() % 199; + for (i = 0; i < n; i++) + g_closure_ref (closure); + g_closure_sink (closure); /* NOP */ + for (i = 0; i < n; i++) + g_closure_unref (closure); +} + +static gpointer +thread1_main (gpointer data) +{ + GClosure *closure = data; + while (!stopping) + { + static guint count = 0; + test_closure (closure); + if (++count % 10000 == 0) + { + g_printerr ("c"); + g_thread_yield(); /* force context switch */ + seen_thread1 = TRUE; + } + } + return NULL; +} + +static gpointer +thread2_main (gpointer data) +{ + GClosure *closure = data; + while (!stopping) + { + static guint count = 0; + test_closure (closure); + if (++count % 10000 == 0) + { + g_printerr ("C"); + g_thread_yield(); /* force context switch */ + seen_thread2 = TRUE; + } + } + return NULL; +} + +static void +test_signal_handler (GTest *test, + gint vint, + gpointer data) +{ + g_assert (data == TEST_POINTER2); + g_assert (test->test_pointer1 == TEST_POINTER1); + seen_signal_handler = TRUE; + seen_test_int1 |= vint == TEST_INT1; + seen_test_int2 |= vint == TEST_INT2; +} + +static void +destroy_data (gpointer data, + GClosure *closure) +{ + seen_cleanup = data == TEST_POINTER2; + g_assert (closure->ref_count == 0); +} + +static void +test_emissions (GTest *test) +{ + g_test_emit_test_signal1 (test, TEST_INT1); + g_test_emit_test_signal2 (test, TEST_INT2); +} + +int +main (int argc, + char **argv) +{ + const gint n_threads = 1; + GThread *thread1, *thread2; + GClosure *closure; + GTest *object; + guint i; + + g_thread_init (NULL); + g_print ("START: %s\n", argv[0]); + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); + g_type_init (); + + object = g_object_new (G_TYPE_TEST, NULL); + closure = g_cclosure_new (G_CALLBACK (test_signal_handler), TEST_POINTER2, destroy_data); + + g_signal_connect_closure (object, "test-signal1", closure, FALSE); + g_signal_connect_closure (object, "test-signal2", closure, FALSE); + + stopping = FALSE; + + thread1 = g_thread_create (thread1_main, closure, TRUE, NULL); + thread2 = g_thread_create (thread2_main, closure, TRUE, NULL); + + for (i = 0; i < 1000000; i++) + { + static guint count = 0; + test_emissions (object); + if (++count % 10000 == 0) + { + g_printerr ("."); + g_thread_yield(); /* force context switch */ + } + } + + stopping = TRUE; + g_print ("\nstopping\n"); + + /* wait for thread shutdown */ + g_thread_join (thread1); + g_thread_join (thread2); + + /* finalize object, destroy signals, run cleanup code */ + g_object_unref (object); + + g_print ("stopped\n"); + + g_assert (seen_thread1 != FALSE); + g_assert (seen_thread2 != FALSE); + g_assert (seen_test_int1 != FALSE); + g_assert (seen_test_int2 != FALSE); + g_assert (seen_signal_handler != FALSE); + g_assert (seen_cleanup != FALSE); + + return 0; +} diff --git a/tests/refcount/objects.c b/tests/refcount/objects.c index 2fb1a6c9..50c4bad9 100644 --- a/tests/refcount/objects.c +++ b/tests/refcount/objects.c @@ -23,7 +23,7 @@ struct _GTestClass }; static GType g_test_get_type (void); -static gboolean stopping; +static volatile gboolean stopping; static void g_test_class_init (GTestClass * klass); static void g_test_init (GTest * test); @@ -96,13 +96,13 @@ g_test_do_refcount (GTest * test) static gpointer run_thread (GTest * test) { - gint i = 0; + gint i = 1; while (!stopping) { g_test_do_refcount (test); - if ((i++ % 100000) == 0) { + if ((i++ % 10000) == 0) { g_print ("."); - g_usleep (1); /* context switch */ + g_thread_yield(); /* force context switch */ } } @@ -115,8 +115,11 @@ main (int argc, char **argv) gint i; GTest *test1, *test2; GArray *test_threads; + const guint n_threads = 5; g_thread_init (NULL); + g_print ("START: %s\n", argv[0]); + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); g_type_init (); test1 = g_object_new (G_TYPE_TEST, NULL); @@ -126,7 +129,7 @@ main (int argc, char **argv) stopping = FALSE; - for (i = 0; i < 20; i++) { + for (i = 0; i < n_threads; i++) { GThread *thread; thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL); @@ -142,7 +145,7 @@ main (int argc, char **argv) g_print ("\nstopping\n"); /* join all threads */ - for (i = 0; i < 40; i++) { + for (i = 0; i < 2 * n_threads; i++) { GThread *thread; thread = g_array_index (test_threads, GThread *, i); diff --git a/tests/refcount/objects2.c b/tests/refcount/objects2.c index 539e89c2..f9837310 100644 --- a/tests/refcount/objects2.c +++ b/tests/refcount/objects2.c @@ -88,6 +88,9 @@ g_test_dispose (GObject * object) static void g_test_do_refcount (GTest * test) { + static guint i = 1; + if (i++ % 100000 == 0) + g_print ("."); g_object_ref (test); g_object_unref (test); } @@ -99,6 +102,8 @@ main (int argc, char **argv) GTest *test; g_thread_init (NULL); + g_print ("START: %s\n", argv[0]); + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); g_type_init (); test = g_object_new (G_TYPE_TEST, NULL); @@ -107,5 +112,7 @@ main (int argc, char **argv) g_test_do_refcount (test); } + g_print ("\n"); + return 0; } diff --git a/tests/refcount/properties.c b/tests/refcount/properties.c index f6514146..90a30e79 100644 --- a/tests/refcount/properties.c +++ b/tests/refcount/properties.c @@ -20,7 +20,7 @@ typedef struct _GTestClass GTestClass; struct _GTest { GObject object; - + gint id; gint dummy; gint count; @@ -32,7 +32,7 @@ struct _GTestClass }; static GType g_test_get_type (void); -static gboolean stopping; +static volatile gboolean stopping; static void g_test_class_init (GTestClass * klass); static void g_test_init (GTest * test); @@ -67,8 +67,7 @@ g_test_get_type (void) NULL }; - test_type = g_type_register_static (G_TYPE_OBJECT, "GTest", - &test_info, 0); + test_type = g_type_register_static (G_TYPE_OBJECT, "GTest", &test_info, 0); } return test_type; } @@ -98,7 +97,8 @@ g_test_class_init (GTestClass * klass) static void g_test_init (GTest * test) { - g_print ("init %p\n", test); + static guint static_id = 1; + test->id = static_id++; } static void @@ -108,8 +108,6 @@ g_test_dispose (GObject * object) test = G_TEST (object); - g_print ("dispose %p!\n", object); - G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -178,14 +176,15 @@ g_test_do_property (GTest * test) static gpointer run_thread (GTest * test) { - gint i = 0; - + gint i = 1; + while (!stopping) { g_test_do_property (test); - if ((i++ % 100000) == 0) { - g_print ("."); - g_usleep (1); /* context switch */ - } + if ((i++ % 10000) == 0) + { + g_print (".%c", 'a' + test->id); + g_thread_yield(); /* force context switch */ + } } return NULL; @@ -197,13 +196,16 @@ main (int argc, char **argv) gint i; GArray *test_objects; GArray *test_threads; + const gint n_threads = 5; g_thread_init (NULL); + g_print ("START: %s\n", argv[0]); + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); g_type_init (); test_objects = g_array_new (FALSE, FALSE, sizeof (GTest *)); - for (i = 0; i < 20; i++) { + for (i = 0; i < n_threads; i++) { GTest *test; test = g_object_new (G_TYPE_TEST, NULL); @@ -217,7 +219,7 @@ main (int argc, char **argv) stopping = FALSE; - for (i = 0; i < 20; i++) { + for (i = 0; i < n_threads; i++) { GThread *thread; GTest *test; @@ -226,14 +228,13 @@ main (int argc, char **argv) thread = g_thread_create ((GThreadFunc) run_thread, test, TRUE, NULL); g_array_append_val (test_threads, thread); } - sleep (5); + sleep (3); stopping = TRUE; - g_print ("\nstopping\n"); /* join all threads */ - for (i = 0; i < 20; i++) { + for (i = 0; i < n_threads; i++) { GThread *thread; thread = g_array_index (test_threads, GThread *, i); @@ -242,7 +243,7 @@ main (int argc, char **argv) g_print ("stopped\n"); - for (i = 0; i < 20; i++) { + for (i = 0; i < n_threads; i++) { GTest *test; test = g_array_index (test_objects, GTest *, i); diff --git a/tests/refcount/properties2.c b/tests/refcount/properties2.c index 94bbe71c..58f7e312 100644 --- a/tests/refcount/properties2.c +++ b/tests/refcount/properties2.c @@ -158,7 +158,9 @@ static void dummy_notify (GObject *object, GParamSpec *pspec) { - count++; + count++; + if (count % 10000 == 0) + g_print ("."); } static void @@ -177,8 +179,10 @@ main (int argc, char **argv) GTest *test; g_thread_init (NULL); + g_print ("START: %s\n", argv[0]); + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); g_type_init (); - + test = g_object_new (G_TYPE_TEST, NULL); g_signal_connect (test, "notify::dummy", G_CALLBACK (dummy_notify), NULL); diff --git a/tests/refcount/signals.c b/tests/refcount/signals.c index 66b516a6..3fb43be2 100644 --- a/tests/refcount/signals.c +++ b/tests/refcount/signals.c @@ -30,7 +30,7 @@ struct _GTestClass }; static GType g_test_get_type (void); -static gboolean stopping; +static volatile gboolean stopping; /* Element signals and args */ enum @@ -204,7 +204,7 @@ g_test_do_prop (GTest * test) static gpointer run_thread (GTest * test) { - gint i = 0; + gint i = 1; while (!stopping) { if (TESTNUM == 1) @@ -213,9 +213,9 @@ run_thread (GTest * test) g_test_do_signal2 (test); if (TESTNUM == 3) g_test_do_prop (test); - if ((i++ % 100000) == 0) { + if ((i++ % 10000) == 0) { g_print ("."); - g_usleep (1); /* context switch */ + g_thread_yield(); /* force context switch */ } } @@ -237,8 +237,11 @@ main (int argc, char **argv) gint i; GTest *test1, *test2; GArray *test_threads; + const gint n_threads = 1; g_thread_init (NULL); + g_print ("START: %s\n", argv[0]); + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); g_type_init (); test1 = g_object_new (G_TYPE_TEST, NULL); @@ -252,7 +255,7 @@ main (int argc, char **argv) stopping = FALSE; - for (i = 0; i < 20; i++) { + for (i = 0; i < n_threads; i++) { GThread *thread; thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL); @@ -268,7 +271,7 @@ main (int argc, char **argv) g_print ("\nstopping\n"); /* join all threads */ - for (i = 0; i < 40; i++) { + for (i = 0; i < 2 * n_threads; i++) { GThread *thread; thread = g_array_index (test_threads, GThread *, i);