⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcc.c

📁 test file nucleus source
💻 C
📖 第 1 页 / 共 5 页
字号:
/*************************************************************************//*                                                                       *//*               Copyright Mentor Graphics Corporation 2002              *//*                         All Rights Reserved.                          *//*                                                                       *//* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS  *//* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS   *//* SUBJECT TO LICENSE TERMS.                                             *//*                                                                       *//*************************************************************************//*************************************************************************//*                                                                       *//* FILE NAME                                               VERSION       *//*                                                                       *//*      tcc.c                                          Nucleus PLUS 1.14 *//*                                                                       *//* COMPONENT                                                             *//*                                                                       *//*      TC - Thread Control                                              *//*                                                                       *//* DESCRIPTION                                                           *//*                                                                       *//*      This file contains the core routines for the Thread Control      *//*      component.                                                       *//*                                                                       *//* DATA STRUCTURES                                                       *//*                                                                       *//*      None                                                             *//*                                                                       *//* FUNCTIONS                                                             *//*                                                                       *//*      TCC_Create_Task                     Create a task                *//*      TCC_Delete_Task                     Delete a task                *//*      TCC_Create_HISR                     Create HISR                  *//*      TCC_Delete_HISR                     Delete HISR                  *//*      TCC_Reset_Task                      Reset the specified task     *//*      TCC_Terminate_Task                  Terminate the specified task *//*      TCC_Resume_Task                     Resume a task                *//*      TCC_Resume_Service                  Resume a task service call   *//*      TCC_Suspend_Task                    Suspend a task               *//*      TCC_Suspend_Service                 Suspend a task service call  *//*      TCC_Task_Timeout                    Task timeout function        *//*      TCC_Task_Sleep                      Task sleep request           *//*      TCC_Relinquish                      Relinquish task execution    *//*      TCC_Time_Slice                      Process task time-slice      *//*      TCC_Current_Task_Pointer            Retrieve current task pointer*//*      TCC_Current_HISR_Pointer            Retrieve current HISR pointer*//*      TCC_Task_Shell                      Task execution shell         *//*      TCC_Signal_Shell                    Signal execution shell       *//*      TCC_Dispatch_LISR                   Dispatch LISR routine        *//*      TCC_Register_LISR                   Register an LISR             *//*                                                                       *//* DEPENDENCIES                                                          *//*                                                                       *//*      cs_extr.h                           Common Service functions     *//*      tc_extr.h                           Thread Control functions     *//*      in_extr.h                           Initialization/Interrupt     *//*                                            functions                  *//*      tm_extr.h                           Timer Control function       *//*      er_extr.h                           Error handling function      *//*      hi_extr.h                           History functions            *//*                                                                       *//* HISTORY                                                               *//*                                                                       *//*         DATE                    REMARKS                               *//*                                                                       *//*      03-01-1993      Created initial version 1.0                      *//*      04-19-1993      Verified version 1.0                             *//*      05-15-1993      Corrected comment problems in                    *//*                      TCC_Control_Signals and                          *//*                      TCC_Register_Signal_Handler,                     *//*                      making version 1.0a                              *//*      05-15-1993      Verified version 1.0a                            *//*      06-01-1993      Modified a multi-line comment                    *//*                      after a #include directive                       *//*                      that gave some compilers a                       *//*                      problem, making version 1.0b                     *//*      06-01-1993      Verified version 1.0b                            *//*      08-09-1993      Corrected pointer retrieval                      *//*                      loop, resulting in version 1.0c                  *//*      08-09-1993      Verified version 1.0c                            *//*      09-19-1993      Corrected an initialization                      *//*                      problem of de-referencing a                      *//*                      NULL pointer, resulting in                       *//*                      version 1.0d                                     *//*      09-19-1993      Verified version 1.0d                            *//*      11-01-1993      Added logic to save unhandled                    *//*                      interrupt vector number in                       *//*                      a global variable, resulting                     *//*                      in version 1.0e                                  *//*      11-01-1993      Verified version 1.0e                            *//*      02-01-1994      Corrected a suspension with                      *//*                      timeout problem that caused                      *//*                      unconditional task suspension                    *//*                      for timeouts and sleeps for 1                    *//*                      tick, resulting in version 1.0f                  *//*      02-01-1994      Verified version 1.0f                            *//*      03-01-1994      Added another routine that                       *//*                      validates resume calls with                      *//*                      the appropriate protection and                   *//*                      added code to clear cleanup                      *//*                      information at task create and                   *//*                      task resume time, resulting in                   *//*                      version 1.0g                                     *//*      03-01-1994      Verified version 1.0g                            *//*      03-01-1994      Moved non-core functions into                    *//*                      supplemental files, changed                      *//*                      function interfaces to match                     *//*                      those in prototype, added                        *//*                      register options, fixed bug                      *//*                      in suspending current task from                  *//*                      a HISR, added a system protect                   *//*                      structure to reduce overhead                     *//*                      in protection, moved resume                      *//*                      validate to error checking                       *//*                      file, resulting in version 1.1                   *//*                                                                       *//*      03-18-1994      Verified version 1.1                             *//*      12-18-1995      Modified TCC_Resume_Service,                     *//*                      resulting in version 1.1+                        *//*                      (SPR 36, 64, 66, 77)                             *//*      04-17-1996      updated to version 1.2                           *//*      06-01-1996      Modified TCC_Suspend_Task                        *//*                      (SPR152) creating version 1.2a                   *//*      10-29-1997      Modified TCC_Resume_Task                         *//*                      (SPR115) creating vresion 1.2b                   *//*      01-23-1998      Released version 1.2b                            *//*      03-20-1998      Corrected problem where tasks                    *//*                      created with NU_NO_PREEMPT in                    *//*                      Application_Initialize would                     *//*                      start in the order of creation                   *//*                      and not in priority order.                       *//*                      SPR455 creates version 1.2c                      *//*      03-24-1998      Released version 1.3.                            *//*      10-02-1998      Another protect problem (1.3a)                   *//*      10-02-1998      Corrected a problem where a                      *//*                      a timer expiration occurs                        *//*                      during signal handler execution                  *//*                      and causes the task to never                     *//*                      run again (SPR 923) creating                     *//*                      version 1.3b.                                    *//*      03-26-1999      Released 1.11m (new release                      *//*                        numbering scheme)                              *//*      04-17-2002      Released version 1.13m                           *//*      11-07-2002      Released version 1.14                            *//*************************************************************************/#define         NU_SOURCE_FILE#include        "in_defs.h"                 /* Initialization defines    */#include        "cs_extr.h"                 /* Common service functions  */#include        "tc_extr.h"                 /* Thread control functions  */#include        "in_extr.h"                 /* Initialization/Interrupt  */                                            /*   functions               */#include        "tm_extr.h"                 /* Timer control functions   */#include        "er_extr.h"                 /* Error handling function   */#include        "hi_extr.h"                 /* History functions         */#include        "profiler.h"                /* Nucleus Profiling header  */#if ((defined(NU_MODULE_SUPPORT)) && (NU_MODULE_SUPPORT > 0))#include        "module/inc/ms_defs.h"      /* MS_Module typedef */#endif/* Define external inner-component global data references.  */extern INT              INC_Initialize_State;extern CS_NODE         *TCD_Created_Tasks_List;extern UNSIGNED         TCD_Total_Tasks;extern TC_TCB          *TCD_Priority_List[TC_PRIORITIES];extern UNSIGNED         TCD_Priority_Groups;extern DATA_ELEMENT     TCD_Sub_Priority_Groups[TC_MAX_GROUPS];extern UNSIGNED_CHAR    TCD_Lowest_Set_Bit[];extern INT              TCD_Highest_Priority;extern TC_TCB          *TCD_Execute_Task;extern VOID            *TCD_Current_Thread;extern UNSIGNED_CHAR    TCD_Registered_LISRs[NU_MAX_VECTORS+1];extern VOID           (*TCD_LISR_Pointers[NU_MAX_LISRS+1])(INT vector);extern INT              TCD_Interrupt_Count;extern INT              TCD_Stack_Switched;extern TC_PROTECT       TCD_List_Protect;extern TC_PROTECT       TCD_System_Protect;extern TC_PROTECT       TCD_LISR_Protect;extern CS_NODE         *TCD_Created_HISRs_List;extern UNSIGNED         TCD_Total_HISRs;extern TC_PROTECT       TCD_HISR_Protect;extern INT              TCD_Unhandled_Interrupt;/* Define external inner-component function calls that are not available to   other components.  */VOID            TCT_Build_Task_Stack(TC_TCB *task_ptr);VOID            TCT_Build_HISR_Stack(TC_HCB *hisr_ptr);VOID            TCT_Build_Signal_Frame(TC_TCB *task_ptr);VOID            TCT_Protect_Switch(TC_TCB *task);VOID            TCT_Signal_Exit(VOID);/* Define internal function calls.  */VOID            TCC_Signal_Shell(VOID);#if defined(NU_MODULE_SUPPORT) && (NU_MODULE_SUPPORT > 0)/* Define service routines "privately" imported from other components */extern MS_MODULE* msd_current_module;STATUS MSC_Bind_Module_HISR(MS_MODULE* module, TC_HCB* hisr);STATUS MSC_Bind_Module_Task(MS_MODULE* module, TC_TCB* task);#endif /* NU_MODULE_SUPPORT *//*************************************************************************//*                                                                       *//* FUNCTION                                                              *//*                                                                       *//*      TCC_Create_Task                                                  *//*                                                                       *//* DESCRIPTION                                                           *//*                                                                       *//*      This function creates a task and then places it on the list of   *//*      created tasks.  All the resources necessary to create the task   *//*      are supplied to this routine.  If specified, the newly created   *//*      task is started.  Otherwise, it is left in a suspended state.    *//*                                                                       *//* CALLED BY                                                             *//*                                                                       *//*      Application                                                      *//*      TCCE_Create_Task                    Error checking shell         *//*                                                                       *//* CALLS                                                                 *//*                                                                       *//*      CSC_Place_On_List                   Add TCB to linked-list       *//*      [HIC_Make_History_Entry]            Make entry in history log    *//*      TCC_Resume_Task                     Start the created task       *//*      TCT_Build_Task_Stack                Build an initial task stack  *//*      [TCT_Check_Stack]                   Stack checking function      *//*      TCT_Control_To_System               Transfer control to system   *//*      TCT_Protect                         Protect created task list    *//*      TCT_Unprotect                       Release protection of list   *//*      TMC_Init_Task_Timer                 Initialize the task's timer  *//*                                                                       *//* INPUTS                                                                *//*                                                                       *//*      task_ptr                            Task control block pointer   *//*      name                                Task name                    *//*      task_entry                          Entry function of the task   *//*      argc                                Optional task parameter      *//*      argv                                Optional task parameter      *//*      stack_address                       Pointer to start of stack    *//*      stack_size                          Size of task stack in bytes  *//*      priority                            Task priority                *//*      time_slice                          Task time slice              *//*      preempt                             Task preemptability flag     *//*      auto_start                          Automatic task start         *//*                                                                       *//* OUTPUTS                                                               *//*                                                                       *//*      NU_SUCCESS                                                       *//*                                                                       *//* HISTORY                                                               *//*                                                                       *//*         DATE                    REMARKS                               */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -