/[guile]/guile/guile-core/libguile/coop-threads.c
ViewVC logotype

Diff of /guile/guile-core/libguile/coop-threads.c

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

revision 1.35 by dirk, Fri Mar 1 00:19:20 2002 UTC revision 1.36 by mvo, Thu Oct 3 22:53:17 2002 UTC
# Line 59  size_t scm_switch_counter = SCM_THREAD_S Line 59  size_t scm_switch_counter = SCM_THREAD_S
59    
60  coop_m scm_critical_section_mutex;  coop_m scm_critical_section_mutex;
61    
62    static SCM all_threads;
63    
64  void  void
65  scm_threads_init (SCM_STACKITEM *i)  scm_threads_init (SCM_STACKITEM *i)
66  {  {
# Line 76  scm_threads_init (SCM_STACKITEM *i) Line 78  scm_threads_init (SCM_STACKITEM *i)
78    coop_mutex_init (&scm_critical_section_mutex);    coop_mutex_init (&scm_critical_section_mutex);
79    
80    coop_global_main.data = 0; /* Initialized in init.c */    coop_global_main.data = 0; /* Initialized in init.c */
81    
82      coop_global_main.handle = scm_cell (scm_tc16_thread,
83                                          (scm_t_bits) &coop_global_main);
84    
85      scm_gc_register_root (&all_threads);
86      all_threads = scm_cons (coop_global_main.handle, SCM_EOL);
87  }  }
88    
89  void  void
# Line 212  scheme_launch_thread (void *p) Line 220  scheme_launch_thread (void *p)
220                       (SCM_STACKITEM *) &thread);                       (SCM_STACKITEM *) &thread);
221    SCM_SET_CELL_WORD_1 (thread, 0);    SCM_SET_CELL_WORD_1 (thread, 0);
222    scm_thread_count--;    scm_thread_count--;
223      all_threads = scm_delq (thread, all_threads);
224    SCM_DEFER_INTS;    SCM_DEFER_INTS;
225  }  }
226    
# Line 264  scm_call_with_new_thread (SCM argl) Line 273  scm_call_with_new_thread (SCM argl)
273         argl variable may not exist in memory when the thread starts.  */         argl variable may not exist in memory when the thread starts.  */
274      t = coop_create (scheme_launch_thread, (void *) argl);      t = coop_create (scheme_launch_thread, (void *) argl);
275      t->data = SCM_ROOT_STATE (root);      t->data = SCM_ROOT_STATE (root);
276        t->handle = thread;
277      SCM_SET_CELL_WORD_1 (thread, (scm_t_bits) t);      SCM_SET_CELL_WORD_1 (thread, (scm_t_bits) t);
278      scm_thread_count++;      scm_thread_count++;
279        all_threads = scm_cons (thread, all_threads);
280      /* Note that the following statement also could cause coop_yield.*/      /* Note that the following statement also could cause coop_yield.*/
281      SCM_ALLOW_INTS;      SCM_ALLOW_INTS;
282    
# Line 353  scm_spawn_thread (scm_t_catch_body body, Line 364  scm_spawn_thread (scm_t_catch_body body,
364    data->handler_data = handler_data;    data->handler_data = handler_data;
365        
366    t = coop_create (c_launch_thread, (void *) data);    t = coop_create (c_launch_thread, (void *) data);
     
367    t->data = SCM_ROOT_STATE (root);    t->data = SCM_ROOT_STATE (root);
368      t->handle = thread;
369    SCM_SET_CELL_WORD_1 (thread, (scm_t_bits) t);    SCM_SET_CELL_WORD_1 (thread, (scm_t_bits) t);
370    scm_thread_count++;    scm_thread_count++;
371      all_threads = scm_cons (thread, all_threads);
372    /* Note that the following statement also could cause coop_yield.*/    /* Note that the following statement also could cause coop_yield.*/
373    SCM_ALLOW_INTS;    SCM_ALLOW_INTS;
374    
# Line 370  scm_spawn_thread (scm_t_catch_body body, Line 382  scm_spawn_thread (scm_t_catch_body body,
382  }  }
383    
384  SCM  SCM
385    scm_current_thread (void)
386    {
387      return coop_global_curr->handle;
388    }
389    
390    SCM
391    scm_all_threads (void)
392    {
393      return all_threads;
394    }
395    
396    scm_root_state *
397    scm_i_thread_root (SCM thread)
398    #define FUNC_NAME "scm_i_thread_root"
399    {
400      SCM_VALIDATE_THREAD (1, thread);
401      return (scm_root_state *)((coop_t *)SCM_THREAD_DATA (thread))->data;
402    }
403    #undef FUNC_NAME
404    
405    SCM
406  scm_join_thread (SCM thread)  scm_join_thread (SCM thread)
407  #define FUNC_NAME s_join_thread  #define FUNC_NAME s_join_thread
408  {  {

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.36

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