mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Added GC thread state, and notes
This commit is contained in:
parent
f3fac78e35
commit
4e9bd1ea02
4 changed files with 22 additions and 0 deletions
|
@ -12,6 +12,9 @@ TODO:
|
|||
|
||||
- multiple mutators, and threading functions/types. probably want this on a new branch, when ready
|
||||
part of this is implementing the beginnings of srfi-18, to create multiple threads, sync them, etc
|
||||
TODO items:
|
||||
- lock writes to symbol table
|
||||
|
||||
- need to cooperate when a mutator is blocked
|
||||
might be able to stop a thread and do a minor GC on it, but no longjmp until after major GC.
|
||||
would need to figure out how to repack gc_cont and args
|
||||
|
|
2
gc.c
2
gc.c
|
@ -1220,6 +1220,8 @@ void gc_thread_data_init(gc_thread_data *thd, int mut_num, char *stack_base, lon
|
|||
thd->stack_traces = calloc(MAX_STACK_TRACES, sizeof(char *));
|
||||
thd->stack_trace_idx = 0;
|
||||
thd->stack_prev_frame = NULL;
|
||||
// thd->thread = NULL;
|
||||
thd->thread_state = CYC_THREAD_STATE_NEW;
|
||||
//thd->mutator_num = mut_num;
|
||||
thd->jmp_start = malloc(sizeof(jmp_buf));
|
||||
thd->gc_args = malloc(sizeof(object) * NUM_GC_ANS);
|
||||
|
|
|
@ -47,9 +47,18 @@
|
|||
/* Define general object type. */
|
||||
typedef void *object;
|
||||
|
||||
/* Threading */
|
||||
typedef enum { CYC_THREAD_STATE_NEW
|
||||
, CYC_THREAD_STATE_RUNNABLE
|
||||
, CYC_THREAD_STATE_TERMINATED
|
||||
} cyc_thread_state_type;
|
||||
|
||||
/* Thread data structures */
|
||||
typedef struct gc_thread_data_t gc_thread_data;
|
||||
struct gc_thread_data_t {
|
||||
// TODO:
|
||||
// pthread_t *thread;
|
||||
cyc_thread_state_type thread_state;
|
||||
// Data needed to initiate stack-based minor GC
|
||||
char *stack_start;
|
||||
char *stack_limit;
|
||||
|
|
|
@ -2491,6 +2491,9 @@ TODO: should rename this function to make it more clear what is really going on
|
|||
*/
|
||||
void Cyc_start_thread(gc_thread_data *thd)
|
||||
{
|
||||
// TODO: should use an atomic set to modify this
|
||||
thd->thread_state = CYC_THREAD_STATE_RUNNABLE;
|
||||
|
||||
/* Tank, load the jump program... */
|
||||
setjmp(*(thd->jmp_start));
|
||||
|
||||
|
@ -3141,6 +3144,9 @@ void *Cyc_init_thread(object thunk)
|
|||
thd->gc_cont = thunk;
|
||||
thd->gc_num_args = 1;
|
||||
thd->gc_args[0] = &Cyc_91end_91thread_67_primitive;
|
||||
// thd->thread = pthread_self(); // TODO: ptr vs instance
|
||||
// returns instance so would need to malloc here
|
||||
// would also need to update termination code to free that memory
|
||||
gc_add_mutator(thd);
|
||||
Cyc_start_thread(thd);
|
||||
return NULL;
|
||||
|
@ -3193,6 +3199,8 @@ void Cyc_end_thread(gc_thread_data *thd)
|
|||
// referenced? might want to do one more minor GC to clear the stack before
|
||||
// terminating the thread
|
||||
|
||||
// TODO: use ATOMIC set to modify this
|
||||
thd->thread_state = CYC_THREAD_STATE_TERMINATED;
|
||||
pthread_exit(NULL); // For now, just a proof of concept
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue