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,26 @@
#include <thread.h>
struct {
struct thread *first;
struct thread *last;
} readyQ = {0,0};
void ready(struct thread *th)
{
if(!readyQ.last)
{
th->tcb.next = 0;
readyQ.first = readyQ.last = th;
} else {
readyQ.last->tcb.next = th;
readyQ.last = th;
}
}
struct thread *scheduler_next()
{
struct thread *th = readyQ.first;
if(!(readyQ.first = th->tcb.next))
readyQ.last = 0;
return th;
}