scheduler logic moved to semaphore.*

This commit is contained in:
2022-08-30 16:25:19 +02:00
parent 4393e89624
commit f5d433f177
4 changed files with 168 additions and 139 deletions

30
scheduler.h Normal file
View File

@@ -0,0 +1,30 @@
/*
* Copyright 2022 Oleg Borodin <borodin@unix7.org>
*
*/
#ifndef SCHEDULER_H_QWERTY
#define SCHEDULER_H_QWERTY
#define SCHEDULER_NUM_TASKS 4
#define TASK_STACK_SIZE 2048
typedef struct {
void (*entry)(void);
void *stack;
unsigned stack_size;
uint32_t sp;
bool runnable;
} task_t;
typedef struct {
task_t tasks[SCHEDULER_NUM_TASKS];
uint8_t current_task;
} scheduler_t;
void scheduler_init(scheduler_t *scheduler);
void scheduler_task(scheduler_t *scheduler, int task_no, void (*entry)(void));
void scheduler_yield(void);
#endif