📄 sched.lst
字号:
C51 COMPILER V6.12 SCHED 12/07/2004 17:58:47 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE SCHED
OBJECT MODULE PLACED IN .\sched.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\..\..\kernel\sched.c INCDIR(d:\rs1.12b\) DEBUG OBJECTEXTEND PRINT(.\sche
-d.lst) OBJECT(.\sched.obj)
stmt level source
1 /*
2 ===============================================================================
3 | Copyright (C) 2004 RuanHaiShen, All rights reserved.
4 | SUMMARY:
5 | Scheduler implementation.
6 |
7 | DESCRIPTION:
8 | See http://www.01s.org for documentation, latest information, license
9 | and contact details.
10 | email:ruanhaishen@01s.org
11 =============================================================================*/
12 /*===========================================================================*/
13 #include "arch/arch.h"
14 #include "inc/queue.h"
15 #include "inc/kernel.h"
16 #include "inc/memory.h"
17 #include "inc/ipc.h"
18 #include "inc/kapi.h"
19
20
21 queue_t _ready_queue;
22 u8 _current_prio;
23 u8 _sched_lock;
24
25 u8 const __const_ _task_map[] =
26 {
27 0xff, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
28 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
29 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
30 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
31 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
32 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
33 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
34 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
35 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
36 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
37 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
38 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
39 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
40 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
41 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
42 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
43 };
44
45
46 void system_init(void)
47 {
48 1 DISABLE_IRQ;
49 1 _sched_lock = 0xff; /*to prevent multitasking*/
50 1 __ready_que_init();
51 1
52 1 __task_init();
53 1 #if CFG_MM_EN > 0
__mm_init();
C51 COMPILER V6.12 SCHED 12/07/2004 17:58:47 PAGE 2
#endif
56 1 }
57
58
59 void system_start(void)
60 {
61 1 u8 next;
62 1
63 1 #if CFG_TASK_INFO_EN > 0
__usrtask_suspend();
#endif
66 1
67 1 if (_sched_lock == 0xff) {
68 2 _sched_lock = 0;
69 2 __ready_que_get(next);
70 2 _current_prio = next;
71 2 __switch_start(_tasks[next].stack);
72 2 }
73 1 }
74
75
76 void __schedule(void)
77 {
78 1 register u8 current;
79 1 register u8 next;
80 1
81 1 CRITICAL_ENTER;
82 1 if (_sched_lock == 0) {
83 2 current = _current_prio;
84 2 __ready_que_get(next);
85 2 if (next != current) {
86 3 hook_schedule(current, next);
87 3 _current_prio = next;
88 3 __switch_to(&_tasks[current].stack, _tasks[next].stack);
89 3 }
90 2 }
91 1 CRITICAL_EXIT;
92 1 }
93
94
95 #if CFG_IPC_EN > 0
/*called under critical path*/
void __ipc_block(queue_t __p_* q, tick_t ticks)
{
register u8 current;
current = _current_prio;
_tasks[current].pend_q = q;
_tasks[current].delay = ticks;
_tasks[current].state |= STATE_BLOCKED;
__ready_que_remove(current);
__queue_add((*q), current);
}
/*called under critical path*/
u8 __ipc_resume(queue_t __p_* q)
{
register u8 next;
if (queue_if0((*q))) {
return NULL_PRIO;
}
C51 COMPILER V6.12 SCHED 12/07/2004 17:58:47 PAGE 3
__queue_get((*q), next);
__queue_remove((*q), next);
_tasks[next].pend_q = NULL;
_tasks[next].state &= ~STATE_BLOCKED;
if (!(_tasks[next].state & STATE_SUSPEND)) {
__ready_que_add(next);
} else {
_tasks[next].state |= STATE_PREREADY;
}
return next;
}
#if CFG_IPC_TIMEOUT_EN > 0
/*called under critical path*/
void __ipc_timeout(queue_t __p_* q)
{
register u8 current;
current = _current_prio;
__queue_remove((*q), current);
_tasks[current].state &= ~STATE_BLOCKED;
_tasks[current].pend_q = NULL;
}
#endif
#endif
144
145 /*called under critical path*/
146 void __queue_remove_f(queue_t __p_* q, u8 prio)
147 {
148 1 __queue_remove((*q), prio);
149 1 }
150
151 /*called under critical path*/
152 void __queue_add_f(queue_t __p_* q, u8 prio)
153 {
154 1 __queue_add((*q), prio);
155 1 }
156
157 void __memclr(void __p_* pdest, u16 size)
158 {
159 1 for (; size > 0; size--) {
160 2 *((u8 __p_*)pdest)++ = 0;
161 2 }
162 1 }
163
164 #if CFG_PRIO_MODE > 0 || CFG_IPC_EN > 0
void __memcpy(void __p_* pdest, const void __p_* psrc, u16 size)
{
for (; size > 0; size--) {
*((u8 __p_*)pdest)++ = *((u8 __p_*)psrc)++;
}
}
#endif
172
173 #if CFG_PRIO_MODE > 1
/*called under critical path*/
bool __prio_if_normal(u8 prio)
{
if (_tasks[prio].state & STATE_READY) {
if (prio == _tasks[prio].prio.normal) {
C51 COMPILER V6.12 SCHED 12/07/2004 17:58:47 PAGE 4
return true;
}
} else if (_tasks[prio].state & STATE_RESERVED) {
return true;
}
return false;
}
#endif
187
188 /*===========================================================================*/
189
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 158 ----
CONSTANT SIZE = 256 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 3 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -