diff options
Diffstat (limited to 'libguile/gc-malloc.c')
-rw-r--r-- | libguile/gc-malloc.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libguile/gc-malloc.c b/libguile/gc-malloc.c index 54a162263..dd7e30432 100644 --- a/libguile/gc-malloc.c +++ b/libguile/gc-malloc.c @@ -130,15 +130,22 @@ scm_realloc (void *mem, size_t size) if (ptr) return ptr; + scm_i_thread_put_to_sleep (); + scm_i_sweep_all_segments ("realloc"); SCM_SYSCALL (ptr = realloc (mem, size)); if (ptr) - return ptr; + { + scm_i_thread_wake_up (); + return ptr; + } scm_igc ("realloc"); scm_i_sweep_all_segments ("realloc"); + scm_i_thread_wake_up (); + SCM_SYSCALL (ptr = realloc (mem, size)); if (ptr) return ptr; @@ -208,11 +215,14 @@ scm_gc_register_collectable_memory (void *mem, size_t size, const char *what) */ if (scm_mallocated > scm_mtrigger) { - unsigned long prev_alloced = scm_mallocated; + unsigned long prev_alloced; float yield; + scm_i_thread_put_to_sleep (); + + prev_alloced = scm_mallocated; scm_igc (what); - scm_i_sweep_all_segments("mtrigger"); + scm_i_sweep_all_segments ("mtrigger"); yield = ((float)prev_alloced - (float) scm_mallocated) / (float) prev_alloced; @@ -243,6 +253,8 @@ scm_gc_register_collectable_memory (void *mem, size_t size, const char *what) fprintf (stderr, "Mtrigger sweep: ineffective. New trigger %d\n", scm_mtrigger); #endif } + + scm_i_thread_wake_up (); } #ifdef GUILE_DEBUG_MALLOC |