我写了一段使用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);
}
请帮我解决这个问题。
提前致谢...
As per 这个手册页 https://docs.oracle.com/cd/E26505_01/html/816-5173/signal.h-3head.htmlSolaris 10 不知道SIGEV_THREAD
, 但只有
The sigev_notify
成员指定异步事件发生时要使用的通知机制。 sigev_notify 成员可以定义为以下值:
SIGEV_NONE
当感兴趣的事件发生时,不会发送异步通知。
SIGEV_SIGNAL
当感兴趣的事件发生时,会生成一个排队信号,其值由应用程序定义。
SIGEV_PORT
当感兴趣的事件发生时,异步通知将传递到事件端口。这sival_ptr
成员指向一个port_notify_t
结构(见port_associate(3C)
)。事件端口标识符以及应用程序定义的 cookie 是port_notify_t
结构
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)