From 059f08cb73ef2b1631f2c89f8c524e27888f6ba5 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sun, 2 Jan 2022 15:53:57 -0800 Subject: Expanded upon memory library --- src/sys/schedule.flat.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/sys/schedule.flat.c (limited to 'src/sys/schedule.flat.c') diff --git a/src/sys/schedule.flat.c b/src/sys/schedule.flat.c new file mode 100644 index 0000000..6eb0d14 --- /dev/null +++ b/src/sys/schedule.flat.c @@ -0,0 +1,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 -- cgit v1.2.1