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 |
{ |
{ |
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 |
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 |
|
|
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 |
|
|
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 |
|
|
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 |
{ |
{ |