为什么timer_create在solaris 10中抛出SIGEV_THREAD错误?
我通过使用timer_create写了一块用于设置定时器来调用一个线程,其中我将sigev_notify设置为SIGEV_THREAD,它给我错误EINVAL(无效参数)但是当我设置sigev_notify时SIGEV_SIGNAL代码工作正常。
我的这段代码即使在solaris 11中也适用于所有操作系统,但对于solaris 10,我给出了错误。
代码如下:
{ 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);
}
请帮我解决这个问题。
提前致谢…
根据这个手册页, Solaris 10不知道SIGEV_THREAD
,而只知道SIGEV_THREAD
sigev_notify
成员指定在发生异步事件时使用的通知机制。 可以使用以下值定义sigev_notify成员:
SIGEV_NONE
发生感兴趣的事件时不会传递异步通知。
SIGEV_SIGNAL
当感兴趣的事件发生时,生成其应用定义的值的排队信号。
SIGEV_PORT
当感兴趣的事件发生时,异步通知被传递到事件端口。
sival_ptr
成员指向port_notify_t
结构(请参阅port_associate(3C)
)。 事件端口标识符以及应用程序定义的cookie是port_notify_t
结构的一部分