aboutsummaryrefslogtreecommitdiff
path: root/later/schedule.flat.c
blob: 6eb0d143deb428819ced9f64fdb9a4cf52a61a38 (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
#ifdef FLAT

#include "../sys/schedule.h"
static struct Task* task_list[256];

static struct Scheduler scheduler = {
	.tasks = task_list,
};

static unsigned int ntask_i = 0;

void add_task(struct Task* t)
{
	scheduler.tasks[ntask_i] = t;
	ntask_i += 1;
	if (ntask_i > 256) {
		ntask_i = 0;
	}
}

unsigned int get_task_length(void)
{
	return ntask_i;
}

void execute_task(void)
{
	if (scheduler.tasks[ntask_i-1] != 0)
		scheduler.tasks[ntask_i-1]->task();
}

#endif