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

📄 timer.c

📁 基于nucleus操作系统的GPRS无线数据传输终端全套源文件。包括支持ARM7的BSP,操作系统
💻 C
字号:
/*************************************************************************
*                                                                       
*    CopyrIght (c)  1993 - 2001 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                    
*                                                                       
*       TIMER.C                                         4.4                                                                                          
*                                                                       
*   COMPONENT
*
*       Timer Event Queue
*
*   DESCRIPTION                                                           
*                                                                       
*       Timer event queue routines used by tcp/ip                           
*                                                                       
*   DATA STRUCTURES
*
*       None
*
*   FUNCTIONS                                                             
*                                                                       
*       tqpost              Insert a timer event into the timer queue 
*                                                                       
*   DEPENDENCIES                                                          
*                                                                       
*       externs.h
*       netevent.h
*                                                                       
*************************************************************************/

#include "net/inc/externs.h"
#include "net/inc/netevent.h"

/*************************************************************************
*                                                                       
*   FUNCTION                                                              
*                                                                       
*       tqpost                                                           
*                                                                       
*   DESCRIPTION                                                           
*                                                                       
*       Insert a timer queue entry into a delta list.  The delta list       
*       queue is ordered by increasing due time.                            
*                                                                       
*   INPUTS                                                               
*                                                                       
*       *tqlist                                                          
*       *tqe                                                             
*                                                                       
*   OUTPUTS                                                              
*                                                                       
*       NU_SUCCESS                                                       
*                                                                       
*************************************************************************/
INT16 tqpost(tqe_t *tqlist, tqe_t *tqe)
{
    tqe_t    *tqpos;
    UNSIGNED duetime = tqe->duetime;   /*  Pick up the duetimer for the new entry. */

  /*  Clear out the new entry's duplist. */
  tqe->duplist.flink = (tqe_t *)NU_NULL;
  tqe->duplist.blink = (tqe_t *)NU_NULL;

  /*  Search to see if this timer needs to be inserted into the list or
      if it is a duplicate entry.  */
  for (tqpos = tqlist->flink; tqpos; tqpos = tqpos->flink)
    if ( (duetime == tqpos->duetime) || (duetime < tqpos->duetime) )
      break;

  /*  If we found something, the new item needs to be added to a duplist or
      it needs to be inserted.  */
  if (tqpos)
  {

    /*  It needs to be added to a duplist. */
    if (tqe->duetime == tqpos->duetime)
    {
      DLL_Enqueue((tqe_t *) &tqpos->duplist, tqe);
    }
    else
    {
      /*  It needs to be inserted. */
      DLL_Insert((tqe_t *) tqlist, tqe, tqpos);
    }
  }
  else
    /*  If we did not find that the new entry has an equal time (duplicate) or
        needed to be inserted, then add it to the end of the list.  */
    DLL_Enqueue((tqe_t *) tqlist, tqe);

  return(NU_SUCCESS);

} /* tqpost */

⌨️ 快捷键说明

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