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

📄 ioc.c

📁 Nucleus OS code一个商业的RTOS
💻 C
📖 第 1 页 / 共 3 页
字号:
/*                                                                       */
/*      task                                Pointer of task to resume    */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      NU_SUCCESS                          If service is successful     */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*      W. Lamie        03-01-1993      Created initial version 1.0      */
/*      D. Lamie        04-19-1993      Verified version 1.0             */
/*      W. Lamie        03-01-1994      Changed function interfaces to   */
/*                                        match prototype, changed       */
/*                                        protection logic, resulting in */
/*                                        version 1.1                    */
/*      R. Pfaff -                                                       */
/*      D. Lamie        03-18-1994      Verified version 1.1             */
/*                                                                       */
/*************************************************************************/
STATUS  IOC_Resume_Driver(NU_TASK *task)
{

TC_PROTECT     *save_protect;               /* Saved protect pointer     */



#ifdef  NU_ENABLE_STACK_CHECK

    /* Call stack checking function to check for an overflow condition.  */
    TCT_Check_Stack();

#endif

#ifdef  NU_ENABLE_HISTORY

    /* Make an entry that corresponds to this function in the system history
       log.  */
    HIC_Make_History_Entry(NU_RESUME_DRIVER_ID, (UNSIGNED) task, 
                                                (UNSIGNED) 0, (UNSIGNED) 0);

#endif

    /* Pickup current protection. */
    save_protect =  TCT_Get_Current_Protect();

    /* Protect against system access.  */
    TCT_System_Protect();

    /* Resume the specified task.  */
    if (TCC_Resume_Task(task, NU_DRIVER_SUSPEND))
    {

        /* Release protection caller had.  */
        TCT_Unprotect_Specific(save_protect);

        /* Transfer control to the system if the resumed task function
           detects a preemption condition.  */
        TCT_Control_To_System();
    }
    else
    {

        /* Determine if there was protection previously in force.  */
        if (save_protect)
        {

            /* Switch to original protection.  */
            TCT_Set_Current_Protect(save_protect);

            /* Release system protection.  */
            TCT_System_Unprotect();
        }
        else

            /* Release system protection.  */
            TCT_Unprotect();
    }

    /* Return the completion status.  */
    return(NU_SUCCESS);
}



/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      IOC_Suspend_Driver                                               */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function suspends a task inside of an I/O driver.  It is    */
/*      the responsibility of the I/O driver to keep track of tasks      */
/*      waiting inside of an I/O driver.                                 */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      William E. Lamie, Accelerated Technology, Inc.                   */
/*                                                                       */
/* CALLED BY                                                             */
/*                                                                       */
/*      Application                                                      */
/*      IOCE_Suspend_Driver                 Error checking shell         */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      [HIC_Make_History_Entry]            Make entry in history log    */
/*      TCC_Suspend_Task                    Suspend calling task         */
/*      TCT_Current_Thread                  Current task thread          */
/*      [TCT_Check_Stack]                   Stack checking function      */
/*      TCT_Get_Current_Protect             Pickup current protect ptr   */
/*      TCT_Set_Suspend_Protect             Setup suspend protect field  */
/*      TCT_System_Protect                  Protect against system access*/
/*      TCT_Unprotect_Specific              Release user protection      */
/*                                                                       */
/* INPUTS                                                                */
/*                                                                       */
/*      terminate_routine                   Termination/Timeout cleanup  */
/*                                            routine                    */
/*      information                         Information pointer of the   */
/*                                            cleanup routine            */
/*      timeout                             Suspension timeout request   */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      NU_SUCCESS                          If service is successful     */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*      W. Lamie        03-01-1993      Created initial version 1.0      */
/*      D. Lamie        04-19-1993      Verified version 1.0             */
/*      W. Lamie        03-01-1994      Changed protection logic,        */
/*                                        resulting in version 1.1       */
/*      R. Pfaff -                                                       */
/*      D. Lamie        03-18-1994      Verified version 1.1             */
/*                                                                       */
/*************************************************************************/
STATUS  IOC_Suspend_Driver(VOID (*terminate_routine)(VOID *), 
                                        VOID *information, UNSIGNED timeout)
{

TC_PROTECT  *suspend_protect;               /* Current protection        */


#ifdef  NU_ENABLE_STACK_CHECK

    /* Call stack checking function to check for an overflow condition.  */
    TCT_Check_Stack();

#endif

#ifdef  NU_ENABLE_HISTORY

    /* Make an entry that corresponds to this function in the system history
       log.  */
    HIC_Make_History_Entry(NU_SUSPEND_DRIVER_ID, (UNSIGNED) terminate_routine, 
                                (UNSIGNED) information, (UNSIGNED) timeout);

#endif


    /* Pickup current protect.  */
    suspend_protect =  TCT_Get_Current_Protect();
    
    /* Setup system protection.  */
    TCT_System_Protect();
    
    /* Release initial protection.  */
    TCT_Unprotect_Specific(suspend_protect);
    
    /* Save suspend protect for timeout and terminate.  */
    TCT_Set_Suspend_Protect(suspend_protect);    

    /* Suspend the calling task.  */
    TCC_Suspend_Task((NU_TASK *) TCT_Current_Thread(), NU_DRIVER_SUSPEND, 
                                terminate_routine, information, timeout);

    /* Return the completion status.  */
    return(NU_SUCCESS);
}


⌨️ 快捷键说明

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