?? tms.c
字號:
/*************************************************************************/
/* */
/* Copyright (c) 1993-1996 Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are governed */
/* by the license agreement. The recipient of this software implicitly */
/* accepts the terms of the license. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* tms.c PLUS 1.2 */
/* */
/* COMPONENT */
/* */
/* TM - Timer Management */
/* */
/* DESCRIPTION */
/* */
/* This file contains supplemental routines for the timer */
/* management component. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* TMS_Create_Timer Create an application timer */
/* TMS_Delete_Timer Delete an application timer */
/* TMS_Reset_Timer Reset application timer */
/* TMS_Control_Timer Enable/Disable application */
/* timer */
/* */
/* DEPENDENCIES */
/* */
/* cs_extr.h Common Service functions */
/* tc_extr.h Thread Control functions */
/* tm_extr.h Timer functions */
/* hi_extr.h History functions */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* W. Lamie 03-01-1994 Created initial version 1.1 from */
/* previous version of TMC.C */
/* R. Pfaff - */
/* D. Lamie 03-18-1994 Verified version 1.1 */
/* M.Q. Qian 04-17-1996 updated to version 1.2 */
/* */
/*************************************************************************/
#define NU_SOURCE_FILE
#include "cs_extr.h" /* Common service functions */
#include "tc_extr.h" /* Thread control functions */
#include "tm_extr.h" /* Timer functions */
#include "hi_extr.h" /* History functions */
/* Define external inner-component global data references. */
extern CS_NODE *TMD_Created_Timers_List;
extern UNSIGNED TMD_Total_Timers;
extern TM_TCB *TMD_Active_Timers_List;
extern INT TMD_Active_List_Busy;
extern TC_PROTECT TMD_Created_List_Protect;
/* Define internal function prototypes. */
VOID TMC_Start_Timer(TM_TCB *timer, UNSIGNED time);
VOID TMC_Stop_Timer(TM_TCB *timer);
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* TMS_Create_Timer */
/* */
/* DESCRIPTION */
/* */
/* This function creates an application timer and places it on the */
/* list of created timers. The timer is activated if designated by */
/* the enable parameter. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology, Inc. */
/* */
/* CALLED BY */
/* */
/* Application */
/* TMSE_Create_Timer Error checking shell */
/* */
/* CALLS */
/* */
/* CSC_Place_On_List Add node to linked-list */
/* [HIC_Make_History_Entry] Make entry in history log */
/* [TCT_Check_Stack] Stack checking function */
/* TCT_Protect Data structure protect */
/* TCT_Unprotect Un-protect data structure */
/* TMS_Control_Timer Enable the new timer */
/* */
/* INPUTS */
/* */
/* timer_ptr Timer control block pointer */
/* name Timer name */
/* expiration_routine Timer expiration routine */
/* id Timer expiration ID */
/* initial_time Initial expiration time */
/* reschedule_time Reschedule expiration time */
/* enable Automatic enable option */
/* */
/* OUTPUTS */
/* */
/* NU_SUCCESS */
/* */
/* 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 prototype, */
/* resulting in version 1.1 */
/* R. Pfaff - */
/* D. Lamie 03-18-1994 Verified version 1.1 */
/* */
/*************************************************************************/
STATUS TMS_Create_Timer(NU_TIMER *timer_ptr, CHAR *name,
VOID (*expiration_routine)(UNSIGNED), UNSIGNED id,
UNSIGNED initial_time, UNSIGNED reschedule_time, OPTION enable)
{
R1 TM_APP_TCB *timer; /* Timer control block ptr */
INT i; /* Working index variable */
/* Move input timer pointer into internal pointer. */
timer = (TM_APP_TCB *) timer_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_CREATE_TIMER_ID, (UNSIGNED) timer,
(UNSIGNED) name, (UNSIGNED) expiration_routine);
#endif
/* First, clear the timer ID just in case it is an old Timer
Control Block. */
timer -> tm_id = 0;
/* Fill in the timer name. */
for (i = 0; i < NU_MAX_NAME; i++)
timer -> tm_name[i] = name[i];
/* Load the timer with the appropriate values. */
timer -> tm_expiration_routine = expiration_routine;
timer -> tm_expiration_id = id;
timer -> tm_expirations = 0;
timer -> tm_initial_time = initial_time;
timer -> tm_reschedule_time = reschedule_time;
timer -> tm_actual_timer.tm_timer_type = TM_APPL_TIMER;
timer -> tm_enabled = NU_FALSE;
/* Initialize link pointers. */
timer -> tm_created.cs_previous = NU_NULL;
timer -> tm_created.cs_next = NU_NULL;
timer -> tm_actual_timer.tm_next_timer = NU_NULL;
timer -> tm_actual_timer.tm_previous_timer= NU_NULL;
timer -> tm_actual_timer.tm_information = (VOID *) timer;
/* Protect against access to the list of created timers. */
TCT_Protect(&TMD_Created_List_Protect);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -