-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathos.h
More file actions
49 lines (39 loc) · 1.02 KB
/
os.h
File metadata and controls
49 lines (39 loc) · 1.02 KB
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
44
45
46
47
48
49
#ifndef _OS_H_
#define _OS_H_
#include <stdint.h>
#include "malloc.h"
#define MAX_TASKS 24
#define MAX_FIFO 10
#define LOW_PRIORITY 100
#define NORMAL_PRIORITY 1000
#define HIGH_PRIORITY 10000
#define AGING_VALUE 10
#define TASK_READY(t) ((t)->status==0 || ((t)->status<0 && ticks_counter >= -(t)->status))
#define TICKS_PER_SEC 10000
typedef int32_t pid_t;
typedef int32_t priority_t;
// 0 = ready
// <0 = -awake time, for example -10000, awake on ticks_counter = 10000
// 1 wait for IO
typedef int32_t status_t;
#define USART_DRIVER_PID 2
//#define USE_USB_DRIVER
#if USE_USB_DRIVER
#define USB_DRIVER_PID 3
#endif
#define STDIN 0
struct FIFOStruct;
typedef struct FIFOStruct FIFO;
typedef struct {
pid_t pid;
priority_t orig_priority;
priority_t priority;
status_t status;
FIFO *mailbox;
uint8_t *program_break;
uint32_t *stack;
} tcb_t;
void os_init();
tcb_t os_create_task(uint32_t *space, void (*start)(), void *param, int stack_size, priority_t priority);
void os_start_schedule(tcb_t tasks[], int num_tasks);
#endif