timer_create在solaris 10中说无效参数?

时间:2017-12-22 12:09:15

标签: c timer time.h

我有一段代码设置一个计时器,它在大多数os中工作非常好,除了在solaris 10中,这里它无法调度函数并且无法使用errno 22(EINVAL)设置timer_create,我不知道为什么会出现这个问题,我尝试检查变量CLOCK_REALTIME,但没有用..我的代码如下:

void set_timer(timer_t  *timer_id, float delay, float interval, 
               timer_callback  func, int val)
{
    int status =0;
    struct itimerspec ts;
    struct sigevent se;

    se.sigev_notify = SIGEV_THREAD;
    se.sigev_value.sival_int = val;
    se.sigev_notify_function = func;
    se.sigev_notify_attributes = NULL;

    status = timer_create(CLOCK_REALTIME, &se, timer_id);

    ts.it_value.tv_sec = abs(delay);
    ts.it_value.tv_nsec = (delay-abs(delay)) * 1e09;
    ts.it_interval.tv_sec = abs(interval);
    ts.it_interval.tv_nsec = (interval-abs(interval)) * 1e09;

    status = timer_settime(*timer_id, 0, &ts, 0);
}

0 个答案:

没有答案