1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

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.
This commit is contained in:
Ludovic Courtès 2008-09-17 22:58:32 +02:00
parent 902578f15a
commit 43adae308c
2 changed files with 1 additions and 64 deletions

View file

@ -1880,61 +1880,8 @@ scm_c_thread_exited_p (SCM thread)
#undef FUNC_NAME #undef FUNC_NAME
static scm_i_pthread_cond_t wake_up_cond; static scm_i_pthread_cond_t wake_up_cond;
int scm_i_thread_go_to_sleep;
static int threads_initialized_p = 0; 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. /* This mutex is used by SCM_CRITICAL_SECTION_START/END.
*/ */

View file

@ -146,13 +146,6 @@ SCM_INTERNAL void *scm_i_with_guile_and_parent (void *(*func)(void *),
void *data, SCM parent); 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_prehistory (SCM_STACKITEM *);
void scm_threads_init_first_thread (void); 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 \ #define SCM_THREAD_SWITCHING_CODE \
do { \ do { } while (0)
if (scm_i_thread_go_to_sleep) \
scm_i_thread_sleep_for_gc (); \
} while (0)
SCM_API SCM scm_call_with_new_thread (SCM thunk, SCM handler); SCM_API SCM scm_call_with_new_thread (SCM thunk, SCM handler);
SCM_API SCM scm_yield (void); SCM_API SCM scm_yield (void);