Simple scheduler

This commit is contained in:
2018-01-10 22:28:55 +01:00
parent 1e2f81a5d8
commit 251b5f71c9
5 changed files with 50 additions and 23 deletions

View File

@@ -0,0 +1,4 @@
#pragma once
void ready(struct thread *th);
struct thread *scheduler_next();

View File

@@ -7,6 +7,7 @@ struct tcb
uintptr_t stack_ptr;
uint64_t tid;
uint64_t state;
struct thread *next;
};
#define TCB_OFFSET (PAGE_SIZE - sizeof(struct tcb))
@@ -31,12 +32,10 @@ struct thread
struct tcb tcb;
};
extern struct thread *threads[];
int current_tid;
struct thread *current_thread;
#define CURRENT_THREAD() (current_thread)
#define CURRENT_THREAD() (threads[current_tid])
struct thread *new_thread(void (*function)());
struct thread *new_thread(void (*function)(void));
void yield();
int get_tid();