📄 tmf.c
字号:
/*************************************************************************//* *//* FUNCTION *//* *//* TMF_Timer_Information *//* *//* DESCRIPTION *//* *//* This function returns information about the specified timer. *//* However, if the supplied timer pointer is invalid, the *//* function simply returns an error status. *//* *//* CALLED BY *//* *//* Application *//* *//* CALLS *//* *//* [TCT_Check_Stack] Stack checking function *//* TCT_System_Protect Protect active timer *//* TCT_Unprotect Release protection *//* *//* INPUTS *//* *//* timer_ptr Pointer to the timer *//* name Destination for the name *//* enable Destination for the enable *//* posture *//* expirations Destination for the total *//* number of expirations *//* id Destination for the timer id *//* initial_time Destination for the initial *//* time *//* reschedule_time Destination for the *//* reschedule time *//* *//* OUTPUTS *//* *//* NU_SUCCESS If a valid timer pointer *//* is supplied *//* NU_INVALID_TIMER If timer pointer invalid *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* 08-09-1993 Corrected problem that caused an *//* invalid application timer ID *//* to be returned to the caller, *//* resulting in version 1.0a *//* 08-09-1993 Verified version 1.0a *//* 03-01-1994 Changed function interface, *//* resulting in version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* 11-18-1996 Corrected SPR220. *//* *//*************************************************************************/STATUS TMF_Timer_Information(NU_TIMER *timer_ptr, CHAR *name, OPTION *enable, UNSIGNED *expirations, UNSIGNED *id, UNSIGNED *initial_time, UNSIGNED *reschedule_time){TM_APP_TCB *timer; /* Timer control block ptr */INT i; /* Working integer variable */STATUS completion; /* Completion status */NU_SUPERV_USER_VARIABLES /* Switch to supervisor mode */ NU_SUPERVISOR_MODE(); /* 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 /* Protect the active list. */ TCT_System_Protect(); /* Determine if this timer ID is valid. */ if ((timer != NU_NULL) && (timer -> tm_id == TM_TIMER_ID)) { /* The timer pointer is valid. Reflect this in the completion status and fill in the actual information. */ completion = NU_SUCCESS; /* Copy the timer's name. */ for (i = 0; i < NU_MAX_NAME; i++) *name++ = timer -> tm_name[i]; /* Determine if the timer is enabled or disabled. */ if (timer -> tm_enabled) *enable = NU_ENABLE_TIMER; else *enable = NU_DISABLE_TIMER; /* Fill in the remaining information. */ *expirations = timer -> tm_expirations; *id = timer -> tm_expiration_id; *initial_time = timer -> tm_initial_time; *reschedule_time = timer -> tm_reschedule_time; } else /* Indicate that the timer pointer is invalid. */ completion = NU_INVALID_TIMER; /* Release protection. */ TCT_Unprotect(); /* Return to user mode */ NU_USER_MODE(); /* Return the appropriate completion status. */ return(completion);}/*************************************************************************//* *//* FUNCTION *//* *//* TMF_Get_Remaining_Time *//* *//* DESCRIPTION *//* *//* This function returns the remaining time before expiration for *//* the specified timer. *//* *//* *//* CALLED BY *//* *//* Application *//* *//* CALLS *//* *//* TCT_System_Protect Protect active timer *//* TCT_Unprotect Release protection *//* *//* INPUTS *//* *//* timer_ptr Pointer to the timer *//* *//* OUTPUTS *//* *//* remaining_time time until timer expiration *//* *//* NU_INVALID_TIMER If timer pointer invalid *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 07-02-1998 Created service call *//* *//*************************************************************************/STATUS TMF_Get_Remaining_Time(NU_TIMER *timer_ptr, UNSIGNED *remaining_time){R1 TM_APP_TCB *timer; TM_TCB *real_TCB; TM_TCB *list_ptr; INT done = 0; STATUS status; NU_SUPERV_USER_VARIABLES /* Switch to supervisor mode */ NU_SUPERVISOR_MODE(); /* Protect against simultaneous access to the active timers list*/ TCT_System_Protect(); list_ptr = TMD_Active_Timers_List; /* Get the application timer Control Block */ timer = (TM_APP_TCB*) timer_ptr; /* Determine if this timer ID is valid. */ if ((timer != NU_NULL) && (timer -> tm_id == TM_TIMER_ID)) { /* The timer pointer is valid. Reflect this in the completion status and fill in the actual information. */ status = NU_SUCCESS; /* Get the actual timer Control block */ real_TCB = &(timer->tm_actual_timer); if (list_ptr == real_TCB) *remaining_time = list_ptr -> tm_remaining_time; else { if( list_ptr == NU_NULL) /* in case no active timers exist */ *remaining_time = 0; else { *remaining_time = list_ptr -> tm_remaining_time; do { /* Move the list pointer to the next timer in the list. */ list_ptr = list_ptr -> tm_next_timer; *remaining_time += list_ptr -> tm_remaining_time; /* Check to see if we have gotten to the specified timer yet */ if (list_ptr == real_TCB) /* Searching is done. */ done = NU_TRUE; }while (!done); } } } else /* Indicate that the timer pointer is invalid. */ status = NU_INVALID_TIMER; TCT_Unprotect(); /* Return to user mode */ NU_USER_MODE(); return (status);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -