forked from embedded2013/rtenv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.h
More file actions
70 lines (59 loc) · 1.83 KB
/
task.h
File metadata and controls
70 lines (59 loc) · 1.83 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef TASK_H_20131005
#define TASK_H_20131005
#define MAX_NAME_CHARS (32)
#define STACK_SIZE 512 /* Size of task stacks in words */
#define TASK_LIMIT 8 /* Max number of tasks we can handle */
#define PRIORITY_DEFAULT 20
#define PRIORITY_LIMIT (PRIORITY_DEFAULT * 2 - 1)
#define TASK_IS_EMPTY 0
#define TASK_CREATED 1
#define TASK_READY 2
#define TASK_WAIT_READ 3
#define TASK_WAIT_WRITE 4
#define TASK_WAIT_INTR 5
#define TASK_WAIT_TIME 6
/* Stack struct of user thread, see "Exception entry and return" */
struct user_thread_stack {
unsigned int r4;
unsigned int r5;
unsigned int r6;
unsigned int r7;
unsigned int r8;
unsigned int r9;
unsigned int r10;
unsigned int fp;
unsigned int _lr; /* Back to system calls or return exception */
unsigned int _r7; /* Backup from isr */
unsigned int r0;
unsigned int r1;
unsigned int r2;
unsigned int r3;
unsigned int ip;
unsigned int lr; /* Back to user thread code */
unsigned int pc;
unsigned int xpsr;
unsigned int stack[STACK_SIZE - 18];
};
/* Task Control Block */
struct task_control_block {
struct user_thread_stack *stack;
int tid;
int status;
int priority;
char name[MAX_NAME_CHARS];
struct task_control_block **prev;
struct task_control_block *next;
};
struct task_info {
struct task_control_block *tasks;
};
char *get_task_status(int status);
struct task_control_block*
task_pop (struct task_control_block **list);
int task_push (struct task_control_block **list,
struct task_control_block *item);
unsigned int *init_task(unsigned int *stack, void (*start)());
void copy_task_name(void *dst, void *src, int char_to_copied);
int find_next_empty_task_slot(struct task_control_block tasks[]);
int is_task_valid(struct task_control_block task[], int tid);
#endif