30 lines
580 B
C
30 lines
580 B
C
#include "alloc.h"
|
|
#include "debug.h"
|
|
#include "interrupts.h"
|
|
#include "kprintf.h"
|
|
#include "process.h"
|
|
#include "thread.h"
|
|
#include "time.h"
|
|
|
|
#include <stddef.h>
|
|
|
|
struct pcb *current_pcb;
|
|
struct tcb *current_tcb;
|
|
|
|
void scheduler(void)
|
|
{
|
|
struct tcb *thread_to_switch;
|
|
if (!current_tcb) {
|
|
thread_to_switch = current_pcb->thread_list;
|
|
} else {
|
|
if (!current_tcb->next) {
|
|
current_pcb = current_pcb->next;
|
|
// TODO switch context
|
|
thread_to_switch = current_pcb->thread_list;
|
|
} else {
|
|
thread_to_switch = current_tcb->next;
|
|
}
|
|
}
|
|
switch_thread(thread_to_switch);
|
|
}
|