问题描述
我通过使用 timer_create 编写了一段代码来设置计时器以调用我将 sigev_notify 设置为 SIGEV_THREAD 的线程,它给了我错误 EINVAL(无效参数)但是当我将 sigev_notify 设置为 SIGEV_SIGNAL 时,代码工作正常.
I wrote a piece of by using timer_create for sets the timer to invoke a thread in which i set sigev_notify as SIGEV_THREAD, it is giving me error EINVAL(Invalid argument) but when i am setting sigev_notify as SIGEV_SIGNAL code is working fine.
我的这段代码适用于所有操作系统,即使是在 solaris 11 中,但对于solaris 10 却给我错误.
my this piece of code is working in all OS even in solaris 11 but for solaris 10 giving me error.
代码如下:
{
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
,但只知道
As per this man-page Solaris 10 does not know SIGEV_THREAD
, but only
sigev_notify
成员指定发生异步事件时要使用的通知机制.可以使用以下值定义 sigev_notify 成员:
SIGEV_NONE
当感兴趣的事件发生时,不会发送异步通知.
No asynchronous notification is delivered when the event of interest occurs.
SIGEV_SIGNAL
当感兴趣的事件发生时,会生成一个排队信号,其值由应用程序定义.
A queued signal, with its value application-defined, is generated when the event of interest occurs.
SIGEV_PORT
当感兴趣的事件发生时,异步通知被传送到事件端口.sival_ptr
成员指向 port_notify_t
结构(请参阅 port_associate(3C)
).事件端口标识符以及应用程序定义的 cookie 是 port_notify_t
结构
An asynchronous notification is delivered to an event port when the event of interest occurs. The sival_ptr
member points to a port_notify_t
structure (see port_associate(3C)
). The event port identifier as well as an application-defined cookie are part of the port_notify_t
structure
这篇关于为什么在solaris 10 中为SIGEV_THREAD 抛出timer_create 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!