/[guile]/guile/guile-core/libguile/gc.c
ViewVC logotype

Diff of /guile/guile-core/libguile/gc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.240 by mdj, Wed Dec 11 06:54:59 2002 UTC revision 1.241 by mdj, Sat Dec 21 18:59:47 2002 UTC
# Line 90  extern unsigned long * __libc_ia64_regis Line 90  extern unsigned long * __libc_ia64_regis
90    
91  unsigned int scm_gc_running_p = 0;  unsigned int scm_gc_running_p = 0;
92    
93    /* Lock this mutex before doing lazy sweeping.
94     */
95    scm_t_rec_mutex scm_i_sweep_mutex;
96    
97  /* Set this to != 0 if every cell that is accessed shall be checked:  /* Set this to != 0 if every cell that is accessed shall be checked:
98   */   */
99  int scm_debug_cell_accesses_p = 0;  int scm_debug_cell_accesses_p = 0;
# Line 144  scm_i_expensive_validation_check (SCM ce Line 148  scm_i_expensive_validation_check (SCM ce
148        else        else
149          {          {
150            counter = scm_debug_cells_gc_interval;            counter = scm_debug_cells_gc_interval;
           scm_i_thread_put_to_sleep ();  
151            scm_igc ("scm_assert_cell_valid");            scm_igc ("scm_assert_cell_valid");
           scm_i_thread_wake_up ();  
152          }          }
153      }      }
154  }  }
# Line 458  SCM_DEFINE (scm_gc, "gc", 0, 0, 0, Line 460  SCM_DEFINE (scm_gc, "gc", 0, 0, 0,
460              "no longer accessible.")              "no longer accessible.")
461  #define FUNC_NAME s_scm_gc  #define FUNC_NAME s_scm_gc
462  {  {
   SCM_DEFER_INTS;  
   scm_i_thread_put_to_sleep ();  
463    scm_igc ("call");    scm_igc ("call");
   scm_i_thread_wake_up ();  
   SCM_ALLOW_INTS;  
464    return SCM_UNSPECIFIED;    return SCM_UNSPECIFIED;
465  }  }
466  #undef FUNC_NAME  #undef FUNC_NAME
# Line 479  scm_gc_for_newcell (scm_t_cell_type_stat Line 477  scm_gc_for_newcell (scm_t_cell_type_stat
477  {  {
478    SCM cell;    SCM cell;
479    
480    scm_i_thread_put_to_sleep ();    scm_rec_mutex_lock (&scm_i_sweep_mutex);
481    
482    *free_cells = scm_i_sweep_some_segments (freelist);    *free_cells = scm_i_sweep_some_segments (freelist);
483    if (*free_cells == SCM_EOL && scm_i_gc_grow_heap_p (freelist))    if (*free_cells == SCM_EOL && scm_i_gc_grow_heap_p (freelist))
# Line 521  scm_gc_for_newcell (scm_t_cell_type_stat Line 519  scm_gc_for_newcell (scm_t_cell_type_stat
519    
520    *free_cells = SCM_FREE_CELL_CDR (cell);    *free_cells = SCM_FREE_CELL_CDR (cell);
521    
522    scm_i_thread_wake_up ();    scm_rec_mutex_unlock (&scm_i_sweep_mutex);
523    
524    return cell;    return cell;
525  }  }
# Line 536  scm_t_c_hook scm_after_gc_c_hook; Line 534  scm_t_c_hook scm_after_gc_c_hook;
534  void  void
535  scm_igc (const char *what)  scm_igc (const char *what)
536  {  {
537      scm_rec_mutex_lock (&scm_i_sweep_mutex);
538    ++scm_gc_running_p;    ++scm_gc_running_p;
539    scm_c_hook_run (&scm_before_gc_c_hook, 0);    scm_c_hook_run (&scm_before_gc_c_hook, 0);
540    
# Line 549  scm_igc (const char *what) Line 548  scm_igc (const char *what)
548  #endif  #endif
549    
550    /* During the critical section, only the current thread may run. */    /* During the critical section, only the current thread may run. */
551  #if 0 /* MDJ 021207 <djurfeldt@nada.kth.se>    scm_i_thread_put_to_sleep ();
        Currently, a much larger piece of the GC is single threaded.  
        Can we shrink it again? */  
   SCM_CRITICAL_SECTION_START;  
 #endif  
552    
553    if (!scm_root || !scm_stack_base || scm_block_gc)    if (!scm_root || !scm_stack_base || scm_block_gc)
554      {      {
# Line 617  scm_igc (const char *what) Line 612  scm_igc (const char *what)
612    scm_c_hook_run (&scm_after_sweep_c_hook, 0);    scm_c_hook_run (&scm_after_sweep_c_hook, 0);
613    gc_end_stats ();    gc_end_stats ();
614    
615  #if 0 /* MDJ 021207 <djurfeldt@nada.kth.se> */    scm_i_thread_wake_up ();
   SCM_CRITICAL_SECTION_END;  
 #endif  
616    
617    /*    /*
618      See above.      See above.
619     */     */
620    scm_c_hook_run (&scm_after_gc_c_hook, 0);    scm_c_hook_run (&scm_after_gc_c_hook, 0);
621    --scm_gc_running_p;    --scm_gc_running_p;
622      scm_rec_mutex_unlock (&scm_i_sweep_mutex);
623    
624    /*    /*
625      For debugging purposes, you could do      For debugging purposes, you could do
# Line 885  scm_init_storage () Line 879  scm_init_storage ()
879  {  {
880    size_t j;    size_t j;
881    
882      /* Fixme: Should use mutexattr from the low-level API. */
883      scm_rec_mutex_init (&scm_i_sweep_mutex, &scm_i_plugin_rec_mutex);
884      
885    j = SCM_NUM_PROTECTS;    j = SCM_NUM_PROTECTS;
886    while (j)    while (j)
887      scm_sys_protects[--j] = SCM_BOOL_F;      scm_sys_protects[--j] = SCM_BOOL_F;

Legend:
Removed from v.1.240  
changed lines
  Added in v.1.241

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26