X-Git-Url: https://git.hcoop.net/bpt/guile.git/blobdiff_plain/29776e85da637ec4d44b2b2822d6934a50c0084b..6774820f1e83a388b3232cd61a66340886b395d8:/libguile/threads.c diff --git a/libguile/threads.c b/libguile/threads.c index 858a1eb3d..77dcbb37a 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -20,6 +20,7 @@ #define _GNU_SOURCE +#include "libguile/boehm-gc.h" #include "libguile/_scm.h" #if HAVE_UNISTD_H @@ -126,17 +127,6 @@ dequeue (SCM q) /*** Thread smob routines */ -static SCM -thread_mark (SCM obj) -{ - scm_i_thread *t = SCM_I_THREAD_DATA (obj); - scm_gc_mark (t->result); - scm_gc_mark (t->join_queue); - scm_gc_mark (t->dynwinds); - scm_gc_mark (t->active_asyncs); - scm_gc_mark (t->continuation_root); - return t->dynamic_state; -} static int thread_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED) @@ -410,7 +400,7 @@ static SCM scm_i_default_dynamic_state; static void guilify_self_1 (SCM_STACKITEM *base) { - scm_i_thread *t = malloc (sizeof (scm_i_thread)); + scm_i_thread *t = scm_gc_malloc (sizeof (scm_i_thread), "thread"); t->pthread = scm_i_pthread_self (); t->handle = SCM_BOOL_F; @@ -434,6 +424,8 @@ guilify_self_1 (SCM_STACKITEM *base) scm_i_pthread_mutex_init (&t->heap_mutex, NULL); t->clear_freelists_p = 0; t->gc_running_p = 0; + t->current_mark_stack_ptr = NULL; + t->current_mark_stack_limit = NULL; t->exited = 0; t->freelist = SCM_EOL; @@ -460,7 +452,7 @@ guilify_self_2 (SCM parent) scm_i_thread *t = SCM_I_CURRENT_THREAD; SCM_NEWSMOB (t->handle, scm_tc16_thread, t); - scm_gc_register_collectable_memory (t, sizeof (scm_i_thread), "thread"); + t->continuation_root = scm_cons (t->handle, SCM_EOL); t->continuation_base = t->base; @@ -934,13 +926,6 @@ typedef struct { #define SCM_MUTEXP(x) SCM_SMOB_PREDICATE (scm_tc16_mutex, x) #define SCM_MUTEX_DATA(x) ((fat_mutex *) SCM_SMOB_DATA (x)) -static SCM -fat_mutex_mark (SCM mx) -{ - fat_mutex *m = SCM_MUTEX_DATA (mx); - scm_gc_mark (m->owner); - return m->waiting; -} static size_t fat_mutex_free (SCM mx) @@ -1175,13 +1160,6 @@ typedef struct { #define SCM_CONDVARP(x) SCM_SMOB_PREDICATE (scm_tc16_condvar, x) #define SCM_CONDVAR_DATA(x) ((fat_cond *) SCM_SMOB_DATA (x)) -static SCM -fat_cond_mark (SCM cv) -{ - fat_cond *c = SCM_CONDVAR_DATA (cv); - return c->waiting; -} - static size_t fat_cond_free (SCM mx) { @@ -1357,30 +1335,7 @@ SCM_DEFINE (scm_broadcast_condition_variable, "broadcast-condition-variable", 1, # define SCM_MARK_BACKING_STORE() #endif -void -scm_threads_mark_stacks (void) -{ - scm_i_thread *t; - for (t = all_threads; t; t = t->next_thread) - { - /* Check that thread has indeed been suspended. - */ - assert (t->top); - - scm_gc_mark (t->handle); -#if SCM_STACK_GROWS_UP - scm_mark_locations (t->base, t->top - t->base); -#else - scm_mark_locations (t->top, t->base - t->top); -#endif - scm_mark_locations ((SCM_STACKITEM *) t->regs, - ((size_t) sizeof(t->regs) - / sizeof (SCM_STACKITEM))); - } - - SCM_MARK_BACKING_STORE (); -} /*** Select */ @@ -1676,18 +1631,15 @@ void scm_init_threads () { scm_tc16_thread = scm_make_smob_type ("thread", sizeof (scm_i_thread)); - scm_set_smob_mark (scm_tc16_thread, thread_mark); scm_set_smob_print (scm_tc16_thread, thread_print); - scm_set_smob_free (scm_tc16_thread, thread_free); + scm_set_smob_free (scm_tc16_thread, thread_free); /* XXX: Could be removed */ scm_tc16_mutex = scm_make_smob_type ("mutex", sizeof (fat_mutex)); - scm_set_smob_mark (scm_tc16_mutex, fat_mutex_mark); scm_set_smob_print (scm_tc16_mutex, fat_mutex_print); scm_set_smob_free (scm_tc16_mutex, fat_mutex_free); scm_tc16_condvar = scm_make_smob_type ("condition-variable", sizeof (fat_cond)); - scm_set_smob_mark (scm_tc16_condvar, fat_cond_mark); scm_set_smob_print (scm_tc16_condvar, fat_cond_print); scm_set_smob_free (scm_tc16_condvar, fat_cond_free);