#ifndef APOS_TCB_H #define APOS_TCB_H /** * @file tcb.h * Process/thread handling. */ #include #include #include /* arch-specific data */ /* process(/main) threads don't have any previous threads */ #define is_proc(t) (!t->prev) struct tcb { struct arch_tcbd tcbd; /* mapping data * TODO: should mem_region_root be renamed mem_root or something? feels * kind of clunky */ union { /* if we're the main thread, we control the memory regions */ struct mem_region_root sp_r; /* if we're not the main thread, we have a pointer to the main * thread */ struct tcb *proc; }; id_t pid; id_t tid; vm_t callback; vm_t thread_stack; vm_t thread_stack_top; vm_t call_stack; vm_t call_stack_top; /* vm root branch */ struct vmem *b_r; /* linked list of threads in this process */ struct tcb *next; struct tcb *prev; }; void init_tcbs(); void destroy_tcbs(); struct tcb *create_thread(struct tcb *p); struct tcb *create_proc(struct tcb *p); stat_t destroy_thread(struct tcb *t); stat_t destroy_proc(struct tcb *p); struct tcb *cur_tcb(); void use_tcb(struct tcb *); struct tcb *get_tcb(id_t tid); stat_t clone_tcb_maps(struct tcb *); stat_t alloc_stacks(struct tcb *); #endif /* APOS_TCB_H */