forked from jorya/raw-os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
raw_idle.c
128 lines (82 loc) · 2.93 KB
/
raw_idle.c
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
raw os - Copyright (C) Lingjun Chen(jorya_txj).
This file is part of raw os.
raw os is free software; you can redistribute it it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 3 of the License, or (at your option) any later version.
raw os is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. if not, write email to jorya.txj@gmail.com
---
A special exception to the LGPL can be applied should you wish to distribute
a combined work that includes raw os, without being obliged to provide
the source code for any proprietary components. See the file exception.txt
for full details of how and when the exception can be applied.
*/
/* 2012-9 Created by jorya_txj
* xxxxxx please added here
*/
#include <raw_api.h>
#if (RAW_SYSTEM_CHECK > 0)
RAW_VOID raw_idle_task(void *p_arg)
{
LIST *iter;
RAW_TASK_OBJ *task_ptr;
PORT_STACK *task_stack;
RAW_U32 free_stack;
RAW_SR_ALLOC();
p_arg = p_arg; /* Make compiler happy ^_^ */
iter = system_debug.task_head.next;
while (1) {
free_stack = 0u;
task_ptr = list_entry(iter,RAW_TASK_OBJ, stack_check_list);
#if (RAW_CPU_STACK_DOWN > 0)
task_stack = task_ptr->task_stack_base;
/*if no more freespace then break*/
while (*task_stack++ == 0u) {
free_stack++;
/*if task free stack space is big than 12% ,then break because we have enougf stack space*/
if (free_stack > (task_ptr->stack_size >> 3)) {
break;
}
}
#else
task_stack = (PORT_STACK *)(task_ptr->task_stack_base) + task_ptr->stack_size - 1;
while (*task_stack-- == 0) {
free_stack++;
/*if task free stack space is big than 12% ,then break because we have enougf stack space*/
if (free_stack > (task_ptr->stack_size >> 3)) {
break;
}
}
#endif
TRACE_TASK_STACK_SPACE(task_ptr);
RAW_CPU_DISABLE();
/*if task is still on the stack check list*/
if (task_ptr->task_state != RAW_DELETED) {
/*if stack space is less than 12%*/
if (free_stack < (task_ptr->stack_size >> 3)) {
RAW_ASSERT(0);
}
iter = iter->next;
/*if meet task head then skip it*/
if (iter == (&(system_debug.task_head))) {
iter = system_debug.task_head.next;
}
}
/*if task is deleted, then move to next*/
else {
iter = system_debug.after_delete_list;
}
RAW_CPU_ENABLE();
}
}
#else
RAW_VOID raw_idle_task (void *p_arg)
{
p_arg = p_arg; /* Make compiler happy ^_^ */
raw_idle_coroutine_hook();
}
#endif