aboutsummaryrefslogtreecommitdiff
path: root/later/schedule.h
blob: 77da7ebfdf0b674c265a3af5f89cc2b6a7cbda74 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef SYS_SCHEDULE_H
#define SYS_SCHEDULE_H

#define S_WAITING 0
#define S_READY 1

#define STACK_SIZE 0x800
struct Task {
	unsigned char priority;
	unsigned char status;
	unsigned long pid;
	void (*task)(void);
	unsigned long reg[16];
	unsigned long stacki;
	void* stack;
};

#ifdef FLAT
struct Scheduler {
	unsigned long running_pid;
	struct Task** tasks;
};
#elseif LL
#include "../lib/ll.h"
struct Scheduler {
	unsigned long running_pid;
	struct LL* tasks;
};
#else
#include "../lib/q.h"
struct Scheduler {
	unsigned long running_pid;
	struct Q_base* tasks;
};
#endif

void add_fxn(void (*task)(void), unsigned char priority);
unsigned char exists(void (*task)(void));
void add_no_repeat(void (*task)(void), unsigned char priority);
unsigned int get_task_length(void);
void execute_task(void);

#endif