📄 os_core.lst
字号:
OS_IDLE_PRIO, /* Lowest priority level
- */
OS_TASK_IDLE_ID,
&OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE - 1], /* Set Bottom-Of-Stack
- */
OS_TASK_IDLE_STK_SIZE,
(void *)0, /* No TCB extension
- */
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);/* Enable stack checking + clear stac
-k */
#endif
#else
181 1 #if OS_STK_GROWTH == 1
(void)OSTaskCreate(OS_TaskIdle,
(void *)0,
&OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE - 1],
OS_IDLE_PRIO);
#else
187 1 (void)OSTaskCreate(OS_TaskIdle,
188 1 (void *)0,
189 1 &OSTaskIdleStk[0],
190 1 OS_IDLE_PRIO);
191 1 #endif
192 1 #endif
193 1
194 1 /* ------------------------------- CREATION OF 'STATISTIC' TASK ---------------------------------- */
195 1 #if OS_TASK_STAT_EN > 0
#if OS_TASK_CREATE_EXT_EN > 0
#if OS_STK_GROWTH == 1
(void)OSTaskCreateExt(OS_TaskStat,
(void *)0, /* No args passed to OS_TaskSta
-t()*/
&OSTaskStatStk[OS_TASK_STAT_STK_SIZE - 1], /* Set Top-Of-Stack
- */
OS_STAT_PRIO, /* One higher than the idle tas
-k */
OS_TASK_STAT_ID,
&OSTaskStatStk[0], /* Set Bottom-Of-Stack
- */
OS_TASK_STAT_STK_SIZE,
C51 COMPILER V8.02 OS_CORE 08/05/2007 21:31:18 PAGE 5
(void *)0, /* No TCB extension
- */
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR); /* Enable stack checking + clea
-r */
#else
(void)OSTaskCreateExt(OS_TaskStat,
(void *)0, /* No args passed to OS_TaskSta
-t()*/
&OSTaskStatStk[0], /* Set Top-Of-Stack
- */
OS_STAT_PRIO, /* One higher than the idle tas
-k */
OS_TASK_STAT_ID,
&OSTaskStatStk[OS_TASK_STAT_STK_SIZE - 1], /* Set Bottom-Of-Stack
- */
OS_TASK_STAT_STK_SIZE,
(void *)0, /* No TCB extension
- */
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR); /* Enable stack checking + clea
-r */
#endif
#else
#if OS_STK_GROWTH == 1
(void)OSTaskCreate(OS_TaskStat,
(void *)0, /* No args passed to OS_TaskSta
-t()*/
&OSTaskStatStk[OS_TASK_STAT_STK_SIZE - 1], /* Set Top-Of-Stack
- */
OS_STAT_PRIO); /* One higher than the idle tas
-k */
#else
(void)OSTaskCreate(OS_TaskStat,
(void *)0, /* No args passed to OS_TaskSta
-t()*/
&OSTaskStatStk[0], /* Set Top-Of-Stack
- */
OS_STAT_PRIO); /* One higher than the idle tas
-k */
#endif
#endif
#endif
232 1
233 1 #if OS_VERSION >= 204
234 1 OSInitHookEnd(); /* Call port specific init. cod
-e */
235 1 #endif
236 1 }
237 /*$PAGE*/
238 /*
239 *********************************************************************************************************
240 * ENTER ISR
241 *
242 * Description: This function is used to notify uC/OS-II that you are about to service an interrupt
243 * service routine (ISR). This allows uC/OS-II to keep track of interrupt nesting and thus
244 * only perform rescheduling at the last nested ISR.
245 *
246 * Arguments : none
247 *
248 * Returns : none
249 *
250 * Notes : 1) Your ISR can directly increment OSIntNesting without calling this function because
251 * OSIntNesting has been declared 'global'. You MUST, however, be sure that the increment
C51 COMPILER V8.02 OS_CORE 08/05/2007 21:31:18 PAGE 6
252 * is performed 'indivisibly' by your processor to ensure proper access to this critical
253 * resource.
254 * 2) You MUST still call OSIntExit() even though you increment OSIntNesting directly.
255 * 3) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every call
256 * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
257 * end of the ISR.
258 *********************************************************************************************************
259 */
260
261 void OSIntEnter (void) KCREENTRANT
262 {
263 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
266 1
267 1
268 1 OS_ENTER_CRITICAL();
269 1 if (OSIntNesting < 255) {
270 2 OSIntNesting++; /* Increment ISR nesting level */
271 2 }
272 1 OS_EXIT_CRITICAL();
273 1 }
274 /*$PAGE*/
275 /*
276 *********************************************************************************************************
277 * EXIT ISR
278 *
279 * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR. When
280 * the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
281 * a new, high-priority task, is ready to run.
282 *
283 * Arguments : none
284 *
285 * Returns : none
286 *
287 * Notes : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every call
288 * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
289 * end of the ISR.
290 * 2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
291 *********************************************************************************************************
292 */
293
294 void OSIntExit (void) KCREENTRANT
295 {
296 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
299 1
300 1
301 1 OS_ENTER_CRITICAL();
302 1 if (OSIntNesting > 0) { /* Prevent OSIntNesting from wrapping */
303 2 OSIntNesting--;
304 2 }
305 1 if ((OSIntNesting == 0) && (OSLockNesting == 0)) { /* Reschedule only if all ISRs complete ... */
306 2 OSIntExitY = OSUnMapTbl[OSRdyGrp]; /* ... and not locked. */
307 2 OSPrioHighRdy = (INT8U)((OSIntExitY << 3) + OSUnMapTbl[OSRdyTbl[OSIntExitY]]);
308 2 if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
309 3 OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
310 3 OSCtxSwCtr++; /* Keep track of the number of context switches */
311 3 OSIntCtxSw(); /* Perform interrupt level context switch */
312 3 }
313 2 }
C51 COMPILER V8.02 OS_CORE 08/05/2007 21:31:18 PAGE 7
314 1 OS_EXIT_CRITICAL();
315 1 }
316 /*$PAGE*/
317 /*
318 *********************************************************************************************************
319 * PREVENT SCHEDULING
320 *
321 * Description: This function is used to prevent rescheduling to take place. This allows your application
322 * to prevent context switches until you are ready to permit context switching.
323 *
324 * Arguments : none
325 *
326 * Returns : none
327 *
328 * Notes : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair. In other words, for every
329 * call to OSSchedLock() you MUST have a call to OSSchedUnlock().
330 *********************************************************************************************************
331 */
332
333 #if OS_SCHED_LOCK_EN > 0
void OSSchedLock (void) KCREENTRANT
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
if (OSRunning == TRUE) { /* Make sure multitasking is running */
OS_ENTER_CRITICAL();
if (OSLockNesting < 255) { /* Prevent OSLockNesting from wrapping back to 0 */
OSLockNesting++; /* Increment lock nesting level */
}
OS_EXIT_CRITICAL();
}
}
#endif
349
350 /*$PAGE*/
351 /*
352 *********************************************************************************************************
353 * ENABLE SCHEDULING
354 *
355 * Description: This function is used to re-allow rescheduling.
356 *
357 * Arguments : none
358 *
359 * Returns : none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -