~cypheon/xos

xos/scheduler.c -rw-r--r-- 459 bytes
567db604 — Johann Rudloff Implement scanning and allocation of physical memory. 7 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <sys/proc.h>
#include <kern/scheduler.h>

struct proc *current;

struct proc *all_proc[256];
int num_procs = 0;
int run_next = 0;

extern void proc_switch(struct proc *proc);

struct proc *
select_next_proc(void) {
  run_next = (run_next + 1) % num_procs;
  return all_proc[run_next];
}

void
sched_run_next_proc(void) {
  current = select_next_proc();
  proc_switch(current);
}

void
sched_add(struct proc *proc) {
  all_proc[num_procs++] = proc;
}