diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 8e1b914e3..93d4c5319 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,12 @@ +2002-12-10 Mikael Djurfeldt + + * threads.c (scm_i_thread_invalidate_freelists): New + function. + + * gc.c (scm_igc): Call scm_i_thread_invalidate_freelists. + + * modules.c (scm_export): Inserted a return statement. + 2002-12-10 Han-Wen Nienhuys * modules.c (scm_export): new function diff --git a/libguile/gc.c b/libguile/gc.c index 9d4d3216a..299dfe4bd 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -570,6 +570,8 @@ scm_igc (const char *what) ++scm_gc_heap_lock; + scm_i_thread_invalidate_freelists (); + /* Let's finish the sweep. The conservative GC might point into the garbage, and marking that would create a mess. diff --git a/libguile/threads.c b/libguile/threads.c index cc3c72838..06fe64d52 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -1158,7 +1158,6 @@ scm_c_thread_exited_p (SCM thread) static scm_t_cond wake_up_cond; int scm_i_thread_go_to_sleep; -static scm_thread *gc_thread; static scm_t_mutex gc_section_mutex; static scm_thread *gc_section_owner; static int gc_section_count = 0; @@ -1177,21 +1176,30 @@ scm_i_thread_put_to_sleep () if (SCM_CAR (threads) != cur_thread) { scm_thread *t = SCM_THREAD_DATA (SCM_CAR (threads)); - t->clear_freelists_p = 1; scm_i_plugin_mutex_lock (&t->heap_mutex); } - gc_thread = suspend (); scm_i_thread_go_to_sleep = 0; } } +void +scm_i_thread_invalidate_freelists () +{ + SCM threads = all_threads; + for (; !SCM_NULLP (threads); threads = SCM_CDR (threads)) + if (SCM_CAR (threads) != cur_thread) + { + scm_thread *t = SCM_THREAD_DATA (SCM_CAR (threads)); + t->clear_freelists_p = 1; + } +} + void scm_i_thread_wake_up () { if (threads_initialized_p && gc_section_count == 1) { SCM threads = all_threads; - resume (gc_thread); scm_i_plugin_cond_broadcast (&wake_up_cond); for (; !SCM_NULLP (threads); threads = SCM_CDR (threads)) if (SCM_CAR (threads) != cur_thread) @@ -1208,11 +1216,8 @@ scm_i_thread_sleep_for_gc () { scm_thread *t; t = suspend (); - *SCM_FREELIST_LOC (scm_i_freelist) = SCM_EOL; - *SCM_FREELIST_LOC (scm_i_freelist2) = SCM_EOL; scm_i_plugin_cond_wait (&wake_up_cond, &t->heap_mutex); - t->clear_freelists_p = 0; - t->top = NULL; /* resume (t); but don't clear freelists */ + resume (t); } /* The mother of all recursive critical sections */ diff --git a/libguile/threads.h b/libguile/threads.h index a3bdb2d91..a438a9c33 100644 --- a/libguile/threads.h +++ b/libguile/threads.h @@ -182,6 +182,7 @@ extern int scm_i_thread_go_to_sleep; void scm_i_thread_put_to_sleep (void); void scm_i_thread_wake_up (void); +void scm_i_thread_invalidate_freelists (void); void scm_i_thread_sleep_for_gc (void); void scm_threads_prehistory (void); void scm_threads_init_first_thread (void);