📄 tx_tte.c
字号:
/**************************************************************************/
/* */
/* Copyright (c) 1996-2000 by Express Logic Inc. */
/* */
/* This software is copyrighted by and is the sole property of Express */
/* Logic, Inc. All rights, title, ownership, or other interests */
/* in the software remain the property of Express Logic, Inc. This */
/* software may only be used in accordance with the corresponding */
/* license agreement. Any unauthorized use, duplication, transmission, */
/* distribution, or disclosure of this software is expressly forbidden. */
/* */
/* This Copyright notice may not be removed or modified without prior */
/* written consent of Express Logic, Inc. */
/* */
/* Express Logic, Inc. reserves the right to modify this software */
/* without notice. */
/* */
/* Express Logic, Inc. */
/* 11440 West Bernardo Court info@expresslogic.com */
/* Suite 366 http://www.expresslogic.com */
/* San Diego, CA 92127 */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** ThreadX Component */
/** */
/** Timer Management (TIM) */
/** */
/**************************************************************************/
/**************************************************************************/
#define TX_SOURCE_CODE
/* Include necessary system files. */
#include "tx_api.h"
#include "tx_tim.h"
#include "tx_thr.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _tx_timer_thread_entry PORTABLE C */
/* 3.0f */
/* AUTHOR */
/* */
/* William E. Lamie, Express Logic, Inc. */
/* */
/* DESCRIPTION */
/* */
/* This function manages thread and application timer expirations. */
/* Actually, from this thread's point of view, there is no difference. */
/* */
/* INPUT */
/* */
/* timer_thread_input Used just for verification */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* Timer Expiration Function */
/* _tx_thread_suspend Thread suspension */
/* */
/* CALLED BY */
/* */
/* ThreadX Scheduler */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 12-31-1996 William E. Lamie Initial Version 3.0 */
/* 11-11-1997 William E. Lamie Modified comment(s), */
/* resulting in version 3.0b. */
/* 12-25-1997 William E. Lamie Added logic to enable timer */
/* deactivation inside of the */
/* expiration routine and */
/* update of the remaining */
/* ticks is now done here, */
/* resulting in version 3.0c. */
/* 03-01-1998 William E. Lamie Moved the re-activate timer */
/* logic into this function */
/* to eliminate the additional */
/* activate function call, */
/* resulting in version 3.0d. */
/* 01-01-1999 William E. Lamie Modified comment(s), */
/* resulting in version 3.0e. */
/* 11-01-1999 William E. Lamie Modified comment(s), */
/* resulting in version 3.0f. */
/* */
/**************************************************************************/
VOID _tx_timer_thread_entry(ULONG timer_thread_input)
{
TX_INTERRUPT_SAVE_AREA
TX_INTERNAL_TIMER *expired_timers; /* Head of expired timers list */
TX_INTERNAL_TIMER *reactivate_timer; /* Dummy list head pointer */
TX_INTERNAL_TIMER **timer_list; /* Timer list pointer */
REG_2 TX_INTERNAL_TIMER *current_timer; /* Current timer pointer */
REG_3 UINT expiration_time; /* Value used for pointer offset*/
VOID (*timeout_function)(ULONG); /* Local timeout function ptr */
ULONG timeout_param; /* Local timeout parameter */
/* Make sure the timer input is correct. This also gets rid of the
silly compiler warnings. */
if (timer_thread_input != TX_TIMER_ID)
return;
/* Set the reactivate_timer to NULL. */
reactivate_timer = TX_NULL;
/* Now go into an infinite loop to process timer expirations. */
do
{
/* First, move the current list pointer and clear the timer
expired value. This allows the interrupt handling portion
to continue looking for timer expirations. */
TX_DISABLE
/* Save the current timer expiration list pointer. */
expired_timers = *_tx_timer_current_ptr;
/* Modify the head pointer in the first timer in the list, if there
is one! */
if (expired_timers)
expired_timers -> tx_list_head = &expired_timers;
/* Set the current list pointer to NULL. */
*_tx_timer_current_ptr = TX_NULL;
/* Move the current pointer up one timer entry wrap if we get to
the end of the list. */
_tx_timer_current_ptr++;
if (_tx_timer_current_ptr == _tx_timer_list_end)
_tx_timer_current_ptr = _tx_timer_list_start;
/* Clear the expired flag. */
_tx_timer_expired = TX_FALSE;
/* Now, restore previous interrupt posture. */
TX_RESTORE
/* Next, process the expiration of the associated timers at this
time slot. */
TX_DISABLE
while (expired_timers)
{
/* Something is on the list. Remove it and process the expiration. */
current_timer = expired_timers;
/* Determine if this is the only timer. */
if (current_timer == expired_timers -> tx_active_next)
{
/* Yes, this is the only timer in the list. */
/* Set the head pointer to NULL. */
expired_timers = TX_NULL;
}
else
{
/* No, not the only expired timer. */
/* Remove this timer from the expired list. */
(current_timer -> tx_active_next) -> tx_active_previous =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -