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

📄 tcs.c

📁 nuclues 内核源代码已经在arm7-9 上作了移植
💻 C
📖 第 1 页 / 共 4 页
字号:



    /* Move input task control block pointer into internal pointer.  */
    task =  (TC_TCB *) task_ptr;


#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_CHANGE_TIME_SLICE_ID, (UNSIGNED) task, 
                                        (UNSIGNED) time_slice, (UNSIGNED) 0);

#endif

    /* Protect the scheduling information.  */
    TCT_Protect(&TCD_System_Protect);

    /* Save the old time slice value.  */
    old_time_slice =  task -> tc_time_slice;
    
    /* Store the new time slice value.  */
    task -> tc_time_slice =      time_slice;
    task -> tc_cur_time_slice =  time_slice;

	/* Bug fix. Let the system know we have started a new time slice */
    TMD_Time_Slice_State = TM_ACTIVE;

#ifdef INCLUDE_PROVIEW
	_RTProf_DumpTask(task,RT_PROF_CHANGE_TIME_SLICE);
#endif 
    /* Release protection of information.  */
    TCT_Unprotect();
    
    /* Return the previous time slice value.  */
    return(old_time_slice);
}


/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      TCS_Control_Signals                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function enables the specified signals and returns the      */
/*      previous enable signal value back to the caller.  If a newly     */
/*      enabled signal is present and a signal handler is registered,    */
/*      signal handling is started.                                      */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Accelerated Technology, Inc.                                     */
/*                                                                       */
/* CALLED BY                                                             */
/*                                                                       */
/*      Application                                                      */
/*      TCSE_Control_Signals                Error checking shell         */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      [HIC_Make_History_Entry]            Make entry in history log    */
/*      TCC_Signal_Shell                    Task signal execution        */
/*      [TCT_Check_Stack]                   Stack checking function      */
/*      TCT_Protect                         Protect against other access */
/*      TCT_Unprotect                       Release protection           */
/*                                                                       */
/* INPUTS                                                                */
/*                                                                       */
/*      enable_signal_mask                  Enable signal mask           */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      Previous signal enable mask                                      */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         DATE                    REMARKS                               */
/*                                                                       */
/*      03-01-1993      Created initial version 1.0                      */
/*      04-19-1993      Verified version 1.0                             */
/*      05-15-1993      Corrected problem with a comment                 */
/*      05-15-1993      Verified comment repair                          */
/*      03-01-1994      Added register optimizations,                    */
/*                      modified protection logic,                       */
/*                      resulting in version 1.1                         */
/*                                                                       */
/*      03-18-1994      Verified version 1.1                             */
/*                                                                       */
/*************************************************************************/
UNSIGNED  TCS_Control_Signals(UNSIGNED enable_signal_mask)
{

R1 TC_TCB      *task;                      /* Task pointer              */
UNSIGNED        old_enable_mask;            /* Old enable signal mask    */


#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_CONTROL_SIGNALS_ID,(UNSIGNED) enable_signal_mask,
                                        (UNSIGNED) 0, (UNSIGNED) 0);

#endif

    /* Pickup the task pointer.  */
    task =  (TC_TCB *) TCD_Current_Thread;

    /* Protect against simultaneous access.  */
    TCT_Protect(&TCD_System_Protect);
    
    /* Pickup the old signal mask.  */
    old_enable_mask =  task -> tc_enabled_signals;
    
    /* Put the new mask in.  */
    task -> tc_enabled_signals =  enable_signal_mask;
    
    /* Now, determine if the signal handler needs to be invoked.  */
    if ((enable_signal_mask & task -> tc_signals) &&
        (!task -> tc_signal_active) &&
        (task -> tc_signal_handler))
    {
    
        /* Signal processing is required.  */
        
        /* Indicate that signal processing is in progress.  */
        task -> tc_signal_active =  NU_TRUE;
        
        /* Clear the saved stack pointer to indicate that this is an
           in line signal handler call.  */
        task -> tc_saved_stack_ptr =  NU_NULL;
        
#ifdef INCLUDE_PROVIEW
	_RTProf_DumpTask(task,RT_PROF_CONTROL_SIGNALS);
#endif 

        /* Release protection from multiple access.  */
        TCT_Unprotect();
        
        /* Call the signal handling shell. */
        TCC_Signal_Shell();
    }
    else
	{

#ifdef INCLUDE_PROVIEW
	_RTProf_DumpTask(task,RT_PROF_CONTROL_SIGNALS);
#endif 
    
        /* Release protection.  */
        TCT_Unprotect();
	}
        
    /* Return the old enable mask.  */
    return(old_enable_mask);
}


/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      TCS_Receive_Signals                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function returns the current signals back to the caller.    */
/*      Note that the signals are cleared automatically.                 */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Accelerated Technology, Inc.                                     */
/*                                                                       */
/* CALLED BY                                                             */
/*                                                                       */
/*      Application                                                      */
/*      TCSE_Receive_Signals                Error checking shell         */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      [HIC_Make_History_Entry]            Make entry in history log    */
/*      [TCT_Check_Stack]                   Stack checking function      */
/*      TCT_Protect                         Protect against other access */
/*      TCT_Unprotect                       Release protection           */
/*                                                                       */
/* INPUTS                                                                */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      Current signals                                                  */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         DATE                    REMARKS                               */
/*                                                                       */
/*      03-01-1993      Created initial version 1.0                      */
/*      04-19-1993      Verified version 1.0                             */
/*      03-01-1994      Modified protection logic,                       */
/*                      resulting in version 1.1                         */
/*                                                                       */
/*      03-18-1994      Verified version 1.1                             */
/*                                                                       */
/*************************************************************************/
UNSIGNED  TCS_Receive_Signals(VOID)
{

TC_TCB          *task;                      /* Task pointer              */
UNSIGNED        signals;                    /* Current signals           */


#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_RECEIVE_SIGNALS_ID, (UNSIGNED) 0, 
                                        (UNSIGNED) 0, (UNSIGNED) 0);

#endif

    /* Pickup the task pointer.  */
    task =  (TC_TCB *) TCD_Current_Thread;

    /* Protect against simultaneous access.  */
    TCT_Protect(&TCD_System_Protect);

    /* Pickup the current events.  */
    signals =  task -> tc_signals;
    
    /* Clear the current signals.  */
    task -> tc_signals =  0;
    
#ifdef INCLUDE_PROVIEW
	_RTProf_DumpTask(task,RT_PROF_RECEIVE_SIGNALS);
#endif

    /* Release protection.  */
    TCT_Unprotect();

    /* Return the signals to the caller.  */
    return(signals);
}


/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      TCS_Register_Signal_Handler                                      */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function registers a signal handler for the calling task.   */
/*      Note that if an enabled signal is present and this is the first  */
/*      registered signal handler call, the signal is processed          */
/*      immediately.                                                     */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Accelerated Technology, Inc.                                     */

⌨️ 快捷键说明

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