?? os_core.lst
字號:
436 void OSIntEnter (void) reentrant //using 0
437 {
438 1 if (OSRunning == TRUE) {
439 2 if (OSIntNesting < 255u) {
440 3 OSIntNesting++; /* Increment ISR nesting level */
441 3 }
442 2 }
443 1 }
444 /*$PAGE*/
445 /*
446 *********************************************************************************************************
447 * EXIT ISR
448 *
449 * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR. When
450 * the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
451 * a new, high-priority task, is ready to run.
452 *
453 * Arguments : none
454 *
455 * Returns : none
456 *
457 * Notes : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every call
458 * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
459 * end of the ISR.
460 * 2) Rescheduling is prevented when the scheduler is locked (see OS_SchedLock())
461 *********************************************************************************************************
462 */
463
464 void OSIntExit (void) reentrant //using 0
465 {
466 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
467 1 OS_CPU_SR cpu_sr;
468 1 #endif
469 1
470 1
471 1 if (OSRunning == TRUE) {
472 2 OS_ENTER_CRITICAL();
473 2 if (OSIntNesting > 0) { /* Prevent OSIntNesting from wrapping */
474 3 OSIntNesting--;
475 3 }
476 2 if (OSIntNesting == 0) { /* Reschedule only if all ISRs complete ... */
477 3 if (OSLockNesting == 0) { /* ... and not locked. */
C51 COMPILER V7.06 OS_CORE 07/18/2003 11:05:56 PAGE 9
478 4 OSIntExitY = OSUnMapTbl[OSRdyGrp];
479 4 OSPrioHighRdy = (INT8U)((OSIntExitY << 3) + OSUnMapTbl[OSRdyTbl[OSIntExitY]]);
480 4 if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
481 5 OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
482 5 #if OS_TASK_PROFILE_EN > 0
483 5 OSTCBHighRdy->OSTCBCtxSwCtr++; /* Inc. # of context switches to this task */
484 5 #endif
485 5 OSCtxSwCtr++; /* Keep track of the number of ctx switches */
486 5 OSIntCtxSw(); /* Perform interrupt level ctx switch */
487 5 }
488 4 }
489 3 }
490 2 OS_EXIT_CRITICAL();
491 2 }
492 1 }
493 /*$PAGE*/
494 /*
495 *********************************************************************************************************
496 * PREVENT SCHEDULING
497 *
498 * Description: This function is used to prevent rescheduling to take place. This allows your application
499 * to prevent context switches until you are ready to permit context switching.
500 *
501 * Arguments : none
502 *
503 * Returns : none
504 *
505 * Notes : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair. In other words, for every
506 * call to OSSchedLock() you MUST have a call to OSSchedUnlock().
507 *********************************************************************************************************
508 */
509
510 #if OS_SCHED_LOCK_EN > 0
511 void OSSchedLock (void) reentrant //using 0
512 {
513 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
514 1 OS_CPU_SR cpu_sr;
515 1 #endif
516 1
517 1
518 1 if (OSRunning == TRUE) { /* Make sure multitasking is running */
519 2 OS_ENTER_CRITICAL();
520 2 if (OSLockNesting < 255u) { /* Prevent OSLockNesting from wrapping back to 0 */
521 3 OSLockNesting++; /* Increment lock nesting level */
522 3 }
523 2 OS_EXIT_CRITICAL();
524 2 }
525 1 }
526 #endif
527
528 /*$PAGE*/
529 /*
530 *********************************************************************************************************
531 * ENABLE SCHEDULING
532 *
533 * Description: This function is used to re-allow rescheduling.
534 *
535 * Arguments : none
536 *
537 * Returns : none
538 *
539 * Notes : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair. In other words, for every
C51 COMPILER V7.06 OS_CORE 07/18/2003 11:05:56 PAGE 10
540 * call to OSSchedLock() you MUST have a call to OSSchedUnlock().
541 *********************************************************************************************************
542 */
543
544 #if OS_SCHED_LOCK_EN > 0
545 void OSSchedUnlock (void) reentrant //using 0
546 {
547 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
548 1 OS_CPU_SR cpu_sr;
549 1 #endif
550 1
551 1
552 1 if (OSRunning == TRUE) { /* Make sure multitasking is running */
553 2 OS_ENTER_CRITICAL();
554 2 if (OSLockNesting > 0) { /* Do not decrement if already 0 */
555 3 OSLockNesting--; /* Decrement lock nesting level */
556 3 if (OSLockNesting == 0) { /* See if scheduler is enabled and ... */
557 4 if (OSIntNesting == 0) { /* ... not in an ISR */
558 5 OS_EXIT_CRITICAL();
559 5 OS_Sched(); /* See if a HPT is ready */
560 5 } else {
561 5 OS_EXIT_CRITICAL();
562 5 }
563 4 } else {
564 4 OS_EXIT_CRITICAL();
565 4 }
566 3 } else {
567 3 OS_EXIT_CRITICAL();
568 3 }
569 2 }
570 1 }
571 #endif
572
573 /*$PAGE*/
574 /*
575 *********************************************************************************************************
576 * START MULTITASKING
577 *
578 * Description: This function is used to start the multitasking process which lets uC/OS-II manages the
579 * task that you have created. Before you can call OSStart(), you MUST have called OSInit()
580 * and you MUST have created at least one task.
581 *
582 * Arguments : none
583 *
584 * Returns : none
585 *
586 * Note : OSStartHighRdy() MUST:
587 * a) Call OSTaskSwHook() then,
588 * b) Set OSRunning to TRUE.
589 * c) Load the context of the task pointed to by OSTCBHighRdy.
590 * d_ Execute the task.
591 *********************************************************************************************************
592 */
593
594 void OSStart (void) reentrant //using 0
595 {
596 1 INT8U y;
597 1 INT8U x;
598 1
599 1
600 1 if (OSRunning == FALSE) {
601 2 y = OSUnMapTbl[OSRdyGrp]; /* Find highest priority's task priority number */
C51 COMPILER V7.06 OS_CORE 07/18/2003 11:05:56 PAGE 11
602 2 x = OSUnMapTbl[OSRdyTbl[y]];
603 2 OSPrioHighRdy = (INT8U)((y << 3) + x);
604 2 OSPrioCur = OSPrioHighRdy;
605 2 OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run */
606 2 OSTCBCur = OSTCBHighRdy;
607 2 OSStartHighRdy(); /* Execute target specific code to start task */
608 2 }
609 1 }
610 /*$PAGE*/
611 /*
612 *********************************************************************************************************
613 * STATISTICS INITIALIZATION
614 *
615 * Description: This function is called by your application to establish CPU usage by first determining
616 * how high a 32-bit counter would count to in 1 second if no other tasks were to execute
617 * during that time. CPU usage is then determined by a low priority task which keeps track
618 * of this 32-bit counter every second but this time, with other tasks running. CPU usage is
619 * determined by:
620 *
621 * OSIdleCtr
622 * CPU Usage (%) = 100 * (1 - ------------)
623 * OSIdleCtrMax
624 *
625 * Arguments : none
626 *
627 * Returns : none
628 *********************************************************************************************************
629 */
630
631 #if OS_TASK_STAT_EN > 0
void OSStatInit (void) reentrant //using 0
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
OSTimeDly(2); /* Synchronize with clock tick */
OS_ENTER_CRITICAL();
OSIdleCtr = 0L; /* Clear idle counter */
OS_EXIT_CRITICAL();
OSTimeDly(OS_TICKS_PER_SEC); /* Determine MAX. idle counter value for 1 second */
OS_ENTER_CRITICAL();
OSIdleCtrMax = OSIdleCtr; /* Store maximum idle counter count in 1 second */
OSStatRdy = TRUE;
OS_EXIT_CRITICAL();
}
#endif
650 /*$PAGE*/
651 /*
652 *********************************************************************************************************
653 * PROCESS SYSTEM TICK
654 *
655 * Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
656 * as a 'clock tick'). This function should be called by the ticker ISR but, can also be
657 * called by a high priority task.
658 *
659 * Arguments : none
660 *
661 * Returns : none
662 *********************************************************************************************************
663 */
C51 COMPILER V7.06 OS_CORE 07/18/2003 11:05:56 PAGE 12
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -