我通过使用timer_create设置计时器来调用一个线程,其中我将sigev_notify设置为SIGEV_THREAD,它给我错误EINVAL(Invalid parameter),但是当我将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);
}
请帮我解决这个问题。
提前致谢...
最佳答案
根据this man-page,Solaris 10不知道SIGEV_THREAD
,而仅
sigev_notify
成员指定发生异步事件时要使用的通知机制。 sigev_notify成员可以用以下值定义:
SIGEV_NONE
感兴趣的事件发生时,不会传递任何异步通知。
SIGEV_SIGNAL
当感兴趣的事件发生时,将生成一个排队的信号,其值由应用程序定义。
SIGEV_PORT
当感兴趣的事件发生时,异步通知将传递到事件端口。 sival_ptr
成员指向port_notify_t
结构(请参见port_associate(3C)
)。事件端口标识符以及应用程序定义的cookie是port_notify_t
结构的一部分