From 43adae308c3827d93ad2b79d073288887a99c47d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 17 Sep 2008 22:58:32 +0200 Subject: [PATCH] Remove code intended to put threads to sleep. Actually, threads would "go to sleep" either by blocking on a heap allocation, or by noticing `scm_i_thread_go_to_sleep' is set when running `SCM_TICK', which limits the applicability of this technique (e.g., it was not appropriate for the shared string code). * libguile/threads.c (scm_i_thread_go_to_sleep, scm_i_thread_put_to_sleep, scm_i_thread_invalidate_freelists, scm_i_thread_wake_up, scm_i_thread_sleep_for_gc): Remove. * libguile/threads.h (scm_i_thread_go_to_sleep, scm_i_thread_put_to_sleep, scm_i_thread_invalidate_freelists, scm_i_thread_wake_up, scm_i_thread_sleep_for_gc): Remove declarations. (SCM_THREAD_SWITCHING_CODE): Do nothing. --- libguile/threads.c | 53 ---------------------------------------------- libguile/threads.h | 12 +---------- 2 files changed, 1 insertion(+), 64 deletions(-) diff --git a/libguile/threads.c b/libguile/threads.c index b1cbba260..e63224fa0 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -1880,61 +1880,8 @@ scm_c_thread_exited_p (SCM thread) #undef FUNC_NAME static scm_i_pthread_cond_t wake_up_cond; -int scm_i_thread_go_to_sleep; static int threads_initialized_p = 0; -void -scm_i_thread_put_to_sleep () -{ - if (threads_initialized_p) - { - scm_i_thread *t; - - scm_leave_guile (); - scm_i_pthread_mutex_lock (&thread_admin_mutex); - - /* Signal all threads to go to sleep - */ - scm_i_thread_go_to_sleep = 1; - for (t = all_threads; t; t = t->next_thread) - scm_i_pthread_mutex_lock (&t->heap_mutex); - scm_i_thread_go_to_sleep = 0; - } -} - -void -scm_i_thread_invalidate_freelists () -{ - /* thread_admin_mutex is already locked. */ - - scm_i_thread *t; - for (t = all_threads; t; t = t->next_thread) - if (t != SCM_I_CURRENT_THREAD) - t->clear_freelists_p = 1; -} - -void -scm_i_thread_wake_up () -{ - if (threads_initialized_p) - { - scm_i_thread *t; - - scm_i_pthread_cond_broadcast (&wake_up_cond); - for (t = all_threads; t; t = t->next_thread) - scm_i_pthread_mutex_unlock (&t->heap_mutex); - scm_i_pthread_mutex_unlock (&thread_admin_mutex); - scm_enter_guile ((scm_t_guile_ticket) SCM_I_CURRENT_THREAD); - } -} - -void -scm_i_thread_sleep_for_gc () -{ - scm_i_thread *t = suspend (); - scm_i_pthread_cond_wait (&wake_up_cond, &t->heap_mutex); - resume (t); -} /* This mutex is used by SCM_CRITICAL_SECTION_START/END. */ diff --git a/libguile/threads.h b/libguile/threads.h index 00fca92e4..4b64989c0 100644 --- a/libguile/threads.h +++ b/libguile/threads.h @@ -146,13 +146,6 @@ SCM_INTERNAL void *scm_i_with_guile_and_parent (void *(*func)(void *), void *data, SCM parent); -extern int scm_i_thread_go_to_sleep; - -SCM_INTERNAL void scm_i_thread_put_to_sleep (void); -SCM_INTERNAL void scm_i_thread_wake_up (void); -SCM_INTERNAL void scm_i_thread_invalidate_freelists (void); -void scm_i_thread_sleep_for_gc (void); - void scm_threads_prehistory (SCM_STACKITEM *); void scm_threads_init_first_thread (void); @@ -162,10 +155,7 @@ SCM_INTERNAL void scm_init_threads_default_dynamic_state (void); #define SCM_THREAD_SWITCHING_CODE \ -do { \ - if (scm_i_thread_go_to_sleep) \ - scm_i_thread_sleep_for_gc (); \ -} while (0) + do { } while (0) SCM_API SCM scm_call_with_new_thread (SCM thunk, SCM handler); SCM_API SCM scm_yield (void); -- 2.20.1