First crack at gc_mutator_thread_runnable

This commit is contained in:
Justin Ethier 2015-12-23 22:34:11 -05:00
parent cc36d6459d
commit c09dc43dde
2 changed files with 19 additions and 7 deletions

24
gc.c
View file

@ -1375,13 +1375,25 @@ void gc_mutator_thread_runnable(gc_thread_data *thd, object result)
CYC_THREAD_STATE_BLOCKED, CYC_THREAD_STATE_BLOCKED,
CYC_THREAD_STATE_RUNNABLE); CYC_THREAD_STATE_RUNNABLE);
if (ATOMIC_GET(&(thd->collector_cooperated))) { if (ATOMIC_GET(&(thd->collector_cooperated))) {
// TODO: printf("DEBUG - Collector cooperated, wait for it to finish\n");
// wait for thd->lock // wait for the collector to finish
// unset async flag pthread_mutex_lock(&(thd->lock));
// transport result to heap, if necessary (IE, is not a value type) pthread_mutex_unlock(&(thd->lock));
// set gc_args[0] to result // unset async flag
// longjmp. assumes gc_cont already set by collector while(!ATOMIC_SET_IF_EQ(&(thd->collector_cooperated), 1, 0)){}
// transport result to heap, if necessary (IE, is not a value type)
if (is_object_type(result)) {
fprintf(stderr, "Unhandled object type result, TODO: implement\n");
exit(1);
}
// Setup value to send to continuation
thd->gc_args[0] = result;
thd->gc_num_args = 1;
// Whoa.
printf("DEBUG - Call into gc_cont setup by collector\n");
longjmp(*(thd->jmp_start), 1);
} else { } else {
// Collector didn't do anything; make a normal continuation call
(((closure)(thd->gc_cont))->fn)(thd, 1, thd->gc_cont, result); (((closure)(thd->gc_cont))->fn)(thd, 1, thd->gc_cont, result);
} }
} }

View file

@ -2112,7 +2112,7 @@ TODO: should rename this function to make it more clear what is really going on
*/ */
void Cyc_start_thread(gc_thread_data *thd) void Cyc_start_thread(gc_thread_data *thd)
{ {
/* Tank, load the jump program... */ // Tank, load the jump program
setjmp(*(thd->jmp_start)); setjmp(*(thd->jmp_start));
#if DEBUG_GC #if DEBUG_GC