Pass around tcbs instead of thread stacks

This commit is contained in:
thomas committed 2018-03-21 23:12:43 +01:00
1 parent 1fca5af522
commit 13946b1758
3 files changed
+17 -14

No files matched your search

+6 -4
View File
@@ -2,7 +2,7 @@
#include <memory.h>
struct tcb
struct thread
{
uintptr_t stack_ptr;
uint64_t tid;
@@ -10,10 +10,10 @@ struct tcb
struct thread *next;
};
#define TCB_OFFSET (PAGE_SIZE - sizeof(struct tcb))
#define TCB_OFFSET (PAGE_SIZE - sizeof(struct thread))
#define SWTCH_STACK_SIZE (0x8*8)
struct thread
struct thread_stack
{
uint8_t stack[TCB_OFFSET-SWTCH_STACK_SIZE];
uint64_t RBP;
@@ -25,9 +25,11 @@ struct thread
uint64_t RBP2;
uint64_t ret;
struct tcb tcb;
struct thread tcb;
}__attribute__((packed));
#define thread_stack(th) (struct thread_stack *)((uintptr_t)th - TCB_OFFSET)
struct thread *new_thread(void (*function)(void));
void yield();
int get_tid();