summaryrefslogtreecommitdiff
path: root/libguile/gc-malloc.c
diff options
context:
space:
mode:
authorMikael Djurfeldt <djurfeldt@nada.kth.se>2002-12-09 13:42:58 +0000
committerMikael Djurfeldt <djurfeldt@nada.kth.se>2002-12-09 13:42:58 +0000
commit9bc4701cd397c375cca4fa77b579af0673e6a584 (patch)
treed8fc0f895724c0b2ffa78f88f80c58b5690909dc /libguile/gc-malloc.c
parentfc85d095600162567fd0aa563eed9e6eada3e889 (diff)
downloadguile-9bc4701cd397c375cca4fa77b579af0673e6a584.tar.gz
* __scm.h (SCM_ALLOW_INTS_ONLY): Removed.
(SCM_NONREC_CRITICAL_SECTION_START, SCM_NONREC_CRITICAL_SECTION_END, SCM_REC_CRITICAL_SECTION_START, SCM_REC_CRITICAL_SECTION_END): New macros. (SCM_CRITICAL_SECTION_START/END): Defined here. * eval.c: Insert SOURCE_SECTION_START / SOURCE_SECTION_END around the three calls to scm_m_expand_body. * gc.h: #include "libguile/pthread-threads.h"; (SCM_FREELIST_CREATE, SCM_FREELIST_LOC): New macros. * gc.c (scm_i_freelist, scm_i_freelist2): Defined to be of type scm_t_key; * gc.c, gc-freelist.c, inline.h: Use SCM_FREELIST_LOC for freelist access. * gc-freelist.c (scm_gc_init_freelist): Create freelist keys. * gc-freelist.c, threads.c (really_launch): Use SCM_FREELIST_CREATE. * gc-malloc.c (scm_realloc, scm_gc_register_collectable_memory): * gc.c (scm_i_expensive_validation_check, scm_gc, scm_gc_for_newcell): Put threads to sleep before doing GC-related heap administration so that those pieces of code are executed single-threaded. We might consider rewriting these code sections in terms of a "call_gc_code_singly_threaded" construct instead of calling the pair of scm_i_thread_put_to_sleep () and scm_i_thread_wake_up (). Also, we would want to have as many of these sections eleminated. * init.c (scm_init_guile_1): Call scm_threads_prehistory. * inline.h: #include "libguile/threads.h" * pthread-threads.h: Macros now conform more closely to the pthreads interface. Some of them now take a second argument. * threads.c, threads.h: Many changes. * configure.in: Temporarily replaced "copt" threads option with new option "pthreads". (USE_PTHREAD_THREADS): Define if pthreads configured.
Diffstat (limited to 'libguile/gc-malloc.c')
-rw-r--r--libguile/gc-malloc.c18
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