diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-05-22 15:05:39 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-05-22 15:05:39 +0300 |
| commit | 5793a61eb824a7b97e9bab5913b595a778205cef (patch) | |
| tree | f31931b924058cb6474b80cd02472940ad8cfcd5 /include/apos/tcb.h | |
| parent | a4851206bef5ceecef18b3fde5be6918a67cca21 (diff) | |
| download | kmi-5793a61eb824a7b97e9bab5913b595a778205cef.tar.gz kmi-5793a61eb824a7b97e9bab5913b595a778205cef.zip | |
improved tcb handling in preparation for processes
Diffstat (limited to 'include/apos/tcb.h')
| -rw-r--r-- | include/apos/tcb.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/include/apos/tcb.h b/include/apos/tcb.h index 11e1b5a..f31bf77 100644 --- a/include/apos/tcb.h +++ b/include/apos/tcb.h @@ -5,14 +5,24 @@ #include <apos/types.h> #include <tcb.h> /* 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 */ - struct mem_region_root sp_r; + 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; @@ -29,15 +39,18 @@ struct tcb { /* vm root branch */ struct vm_branch *b_r; - struct tcb *parent; + /* linked list of threads in this process */ struct tcb *next; + struct tcb *prev; }; void init_tcbs(); void destroy_tcbs(); -struct tcb *new_thread(); -void destroy_thread(struct tcb *); +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 *); |
