Linux下只拥有一个定时器,setitimer一个进程中只能有一个,下一个会覆盖前一个的定时器,想一个进程开启多个定时器只能自己实现。
<pre name="code" class="plain">1)定义声明
/* ================================================
Name : SYS_Time.h
Author : HS_NEU
Version : v1.0.0
Copyright :
Description :
date : 2013-11-22
================================================== */
#ifndef _SYS_TIME_H_
#define _SYS_TIME_H_
/* ============= INCLUDE ============= */
#include "debug.h"
#include <time.h>
#define SYS_RET_OK (0)
#define SYS_RET_ERR (-1)
#define TIMER_SINGLE (0)
#define TIMER_CYCLE (1)
/* ============= MACRO ============= */
#define TIMER_NUM_MAX (20)
/* ============= ENUM ============== */
/* ============= STRUCTURE ========= */
typedef void(*TimerCallBack)();
typedef struct _sys_TimerNode_str{
timer_t timer;
int timerID;
int useFlag;
TimerCallBack func;
//void *callBackArg;
int mode;
}SYS_TimeNode_STR;
/* ============= VARIABLE ========== */
/* =