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

📄 nu.c

📁 NecluesRTX RTOS的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
    
    /* Move this task to the end of the list of ready tasks.  */
    if (SKP_Move_To_End())
    {

        /* Leave this task temporarily.  */
        SKD_Leave_Task();
    }    

    /* Restore interrupt level prior to the call.  */
    IND_Set_Interrupt_Level(interrupt_level);

    /* Return the status to caller.  */
    return(NU_SUCCESS);
}                                           /* end of NU_Relinquish     */



/************************************************************************/
/*                                                                      */
/*  FUNCTION                             "NU_Start"                     */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This function is used to place the specified task on the ready  */
/*      task list in preparation for execution.                         */
/*                                                                      */
/*  AUTHOR                                                              */
/*                                                                      */
/*      William E. Lamie,  Accelerated Technology                       */
/*                                                                      */
/*  CALLED FROM                                                         */
/*                                                                      */
/*      Application Routines                                            */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      DS_Make_History_Entry               Make an history entry       */
/*      SKP_Get_Task_ID                     Get the current task ID     */
/*      SKP_Ready_Task                      Place task on ready chain   */
/*      SKD_Leave_Task                      Leave the task              */
/*      IND_Set_Interrupt_Level             Disable/Enable interrupts   */
/*                                                                      */
/*  INPUTS                                                              */
/*                                                                      */
/*      task_id                             Selected task's ID          */
/*                                                                      */
/*  OUTPUTS                                                             */
/*                                                                      */
/*      return(status)                      Status of request           */
/*                                                                      */
/************************************************************************/
signed int  NU_Start(signed int task_id)
{

int                interrupt_level;         /* Saved interrupt level    */
unsigned int       temp;                    /* Temporary variable       */
signed int         status;                  /* Return status            */

    /* Make an entry in the history table, if the conditional compilation
       flag is set.  */
    #ifdef  NU_ENABLE_HISTORY
    DS_Make_History_Entry(NU_HIST_NU_START, (unsigned int) task_id, 0);
    #endif

    /* Initialize the return value.  */
    status =  NU_SUCCESS;

    /* Check for a valid task ID entry.  */
    if ((task_id >= 0) && (task_id < NU_Total_Tasks))
    {

        /* Lock out interrupts while checking.  */
        interrupt_level =  IND_Set_Interrupt_Level(NU_DISABLE_INTERRUPTS);
    
        /* Get the current task's status to determine if the task is 
           suspended.  */
        status =  SKP_Retrieve_Status(task_id, &temp);

        /* If the task is suspended, ready it and set the status to 
           NU_SUCCESS.  */
        if (status != NU_READY)
        {
        
            /* Call "SKP_Ready_Task" to place this task on the ready list.  */
            if (SKP_Ready_Task(task_id))
            {
    
                /* Call "SKD_Leave_Task" to go back to the executive to 
                   perform the context switch.  */
                SKD_Leave_Task();
            }

            /* Successful request.  */
            status =  NU_SUCCESS;
        }
        else
        
            /* Status as not suspended. */
            status =  NU_NOT_SUSPENDED;

        /* Restore interrupt level prior to the call.  */
        IND_Set_Interrupt_Level(interrupt_level);
    }
    else
    
        /* Invalid task id, status as such.  */
        status =  NU_INVALID_TASK;

    /* Return the status to caller.  */
    return(status);
}                                           /* end of NU_Start          */



/************************************************************************/
/*                                                                      */
/*  FUNCTION                             "NU_Stop"                      */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This function is used to suspend the specified task.  If the    */
/*      specified task is the current task, the caller is suspended.    */
/*                                                                      */
/*  AUTHOR                                                              */
/*                                                                      */
/*      William E. Lamie,  Accelerated Technology                       */
/*                                                                      */
/*  CALLED FROM                                                         */
/*                                                                      */
/*      Application Routines                                            */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      DS_Make_History_Entry               Make an history entry       */
/*      SKP_Suspend_Task                    Suspend task specified      */
/*      IND_Set_Interrupt_Level             Disable/Enable interrupts   */
/*                                                                      */
/*  INPUTS                                                              */
/*                                                                      */
/*      task_id                             Selected task's ID          */
/*                                                                      */
/*  OUTPUTS                                                             */
/*                                                                      */
/*      return(status)                      Status of request           */
/*                                                                      */
/************************************************************************/
signed int  NU_Stop(signed int task_id)
{

int                interrupt_level;         /* Saved interrupt level    */
signed int         status;                  /* Return status            */

    /* Make an entry in the history table, if the conditional compilation
       flag is set.  */
    #ifdef  NU_ENABLE_HISTORY
    DS_Make_History_Entry(NU_HIST_NU_STOP, (unsigned int) task_id, 0);
    #endif

    /* Initialize the return value.  */
    status =  NU_SUCCESS;

    /* Check for a valid task ID entry.  */
    if ((task_id >= 0) && (task_id < NU_Total_Tasks))
    {

        /* Lock out interrupts while checking.  */
        interrupt_level =  IND_Set_Interrupt_Level(NU_DISABLE_INTERRUPTS);
    
        /* Call "SKP_Suspend_Task" to remove task from ready list.  */
        status =  SKP_Suspend_Task(task_id, NU_PURE_SUSPEND);
    
        /* Restore interrupt level prior to the call.  */
        IND_Set_Interrupt_Level(interrupt_level);
    }
    else
    
        /* Invalid task id, status as such.  */
        status =  NU_INVALID_TASK;

    /* Return the status to caller.  */
    return(status);
}                                           /* end of NU_Stop           */



/************************************************************************/
/*                                                                      */
/*  FUNCTION                             "NU_Reset"                     */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This function is used to set the task to the original set of    */
/*      conditions.  This includes such things as the task's stack and  */
/*      entrance.                                                       */
/*                                                                      */
/*  AUTHOR                                                              */
/*                                                                      */
/*      William E. Lamie,  Accelerated Technology                       */
/*                                                                      */
/*  CALLED FROM                                                         */
/*                                                                      */
/*      Application Routines                                            */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      DS_Make_History_Entry               Make an history entry       */
/*      SKP_Reset_Task                      Reset task specified        */
/*      IND_Set_Interrupt_Level             Disable/Enable interrupts   */
/*                                                                      */
/*  INPUTS                                                              */
/*                                                                      */
/*      task_id                             Selected task's ID          */
/*                                                                      */
/*  OUTPUTS                                                             */
/*                                                                      */
/*      return(status)                      Status of request           */
/*                                                                      */
/************************************************************************/
signed int  NU_Reset(signed int task_id)
{

int                interrupt_level;         /* Saved interrupt level    */
signed int         status;                  /* Return status            */

    /* Make an entry in the history table, if the conditional compilation
       flag is set.  */
    #ifdef  NU_ENABLE_HISTORY
    DS_Make_History_Entry(NU_HIST_NU_RESET, (unsigned int) task_id, 0);
    #endif

    /* Initialize the return value.  */
    status =  NU_SUCCESS;

    /* Check for a valid task ID entry.  */
    if ((task_id >= 0) && (task_id < NU_Total_Tasks))
    {

        /* Lock out interrupts while resetting.  */
        interrupt_level =  IND_Set_Interrupt_Level(NU_DISABLE_INTERRUPTS);
    
        /* Call "SKP_Reset_Task" to re-initialize the specified task.  */
        status =  SKP_Reset_Task(task_id);
    
        /* Restore interrupt level prior to the call.  */
        IND_Set_Interrupt_Level(interrupt_level);

⌨️ 快捷键说明

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