diff options
author | Marius Vollmer <mvo@zagadka.de> | 2005-01-24 19:14:54 +0000 |
---|---|---|
committer | Marius Vollmer <mvo@zagadka.de> | 2005-01-24 19:14:54 +0000 |
commit | a54a94b39707f47a1f30533bcf7664094d65d073 (patch) | |
tree | 69a524a4c3fbb084e1e2fef05da61e1852700909 /libguile/gc.c | |
parent | be1b896c82273d97b79cd839d7281b46e54920f8 (diff) | |
download | guile-a54a94b39707f47a1f30533bcf7664094d65d073.tar.gz |
Threading changes.
Diffstat (limited to 'libguile/gc.c')
-rw-r--r-- | libguile/gc.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/libguile/gc.c b/libguile/gc.c index c1d489c40..eba337151 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -15,6 +15,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define _GNU_SOURCE /* #define DEBUGINFO */ @@ -71,7 +72,7 @@ unsigned int scm_gc_running_p = 0; /* Lock this mutex before doing lazy sweeping. */ -scm_t_rec_mutex scm_i_sweep_mutex; +pthread_mutex_t scm_i_sweep_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; /* Set this to != 0 if every cell that is accessed shall be checked: */ @@ -206,9 +207,6 @@ SCM_DEFINE (scm_set_debug_cell_accesses_x, "set-debug-cell-accesses!", 1, 0, 0, -scm_t_key scm_i_freelist; -scm_t_key scm_i_freelist2; - /* scm_mtrigger * is the number of bytes of malloc allocation needed to trigger gc. @@ -447,7 +445,7 @@ scm_gc_for_newcell (scm_t_cell_type_statistics *freelist, SCM *free_cells) { SCM cell; - scm_rec_mutex_lock (&scm_i_sweep_mutex); + scm_pthread_mutex_lock (&scm_i_sweep_mutex); *free_cells = scm_i_sweep_some_segments (freelist); if (*free_cells == SCM_EOL && scm_i_gc_grow_heap_p (freelist)) @@ -489,7 +487,7 @@ scm_gc_for_newcell (scm_t_cell_type_statistics *freelist, SCM *free_cells) *free_cells = SCM_FREE_CELL_CDR (cell); - scm_rec_mutex_unlock (&scm_i_sweep_mutex); + pthread_mutex_unlock (&scm_i_sweep_mutex); return cell; } @@ -504,7 +502,7 @@ scm_t_c_hook scm_after_gc_c_hook; void scm_igc (const char *what) { - scm_rec_mutex_lock (&scm_i_sweep_mutex); + scm_pthread_mutex_lock (&scm_i_sweep_mutex); ++scm_gc_running_p; scm_c_hook_run (&scm_before_gc_c_hook, 0); @@ -608,7 +606,7 @@ scm_igc (const char *what) */ --scm_gc_running_p; scm_c_hook_run (&scm_after_gc_c_hook, 0); - scm_rec_mutex_unlock (&scm_i_sweep_mutex); + pthread_mutex_unlock (&scm_i_sweep_mutex); /* For debugging purposes, you could do @@ -890,18 +888,13 @@ scm_storage_prehistory () scm_c_hook_init (&scm_after_gc_c_hook, 0, SCM_C_HOOK_NORMAL); } -scm_t_mutex scm_i_gc_admin_mutex; +pthread_mutex_t scm_i_gc_admin_mutex = PTHREAD_MUTEX_INITIALIZER; int scm_init_storage () { size_t j; - /* Fixme: Should use mutexattr from the low-level API. */ - scm_rec_mutex_init (&scm_i_sweep_mutex, &scm_i_plugin_rec_mutex); - - scm_i_plugin_mutex_init (&scm_i_gc_admin_mutex, &scm_i_plugin_mutex); - j = SCM_NUM_PROTECTS; while (j) scm_sys_protects[--j] = SCM_BOOL_F; @@ -919,6 +912,10 @@ scm_init_storage () if (!scm_i_port_table) return 1; +#if 0 + /* We can't have a cleanup handler since we have no thread to run it + in. */ + #ifdef HAVE_ATEXIT atexit (cleanup); #else @@ -927,6 +924,8 @@ scm_init_storage () #endif #endif +#endif + scm_stand_in_procs = scm_c_make_hash_table (257); scm_permobjs = SCM_EOL; scm_protects = scm_c_make_hash_table (31); |