/************************* *功能:获取时钟间隔 *参数:which:设置哪个时钟 * ITIMER_REAL:实时递减,超时发送SIGALRM信号 * ITIMER_VIRTURL:虚拟时钟,超时发送SIGVALRM时钟 * ITIMER_PROF: * **********************/ int getitimer(int which, struct itimerval *curr_value); /************************* *功能:设置时钟间隔 *参数:which:设置哪个时钟 * ITIMER_REAL:实时递减,超时发送SIGALRM信号 * ITIMER_VIRTURL:虚拟时钟,超时发送SIGVALRM时钟 * ITIMER_PROF: * new_value:新的时钟 * old_value:旧时间 * **********************/ int setitimer(int which, const struct itimerval *new_value,struct itimerval *old_value);
//时间赋值是原子操作 struct itimerval { struct timeval it_interval; /* next value */ struct timeval it_value; /* current value */ }; struct timeval { long tv_sec; /* seconds */ long tv_usec; /* microseconds */ };