forked from embedded2013/rtenv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.c
More file actions
executable file
·43 lines (40 loc) · 941 Bytes
/
Copy pathtask.c
File metadata and controls
executable file
·43 lines (40 loc) · 941 Bytes
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
#include <stddef.h>
#include "task.h"
unsigned int *init_task(unsigned int *stack, void (*start)())
{
stack += STACK_SIZE - 9; /* End of stack, minus what we're about to push */
stack[8] = (unsigned int)start;
return stack;
}
int task_push (struct task_control_block **list, struct task_control_block *item)
{
if (list && item) {
/* Remove itself from original list */
if (item->prev)
*(item->prev) = item->next;
if (item->next)
item->next->prev = item->prev;
/* Insert into new list */
while (*list) list = &((*list)->next);
*list = item;
item->prev = list;
item->next = NULL;
return 0;
}
return -1;
}
struct task_control_block* task_pop (struct task_control_block **list)
{
if (list) {
struct task_control_block *item = *list;
if (item) {
*list = item->next;
if (item->next)
item->next->prev = list;
item->prev = NULL;
item->next = NULL;
return item;
}
}
return NULL;
}