how to send event from driver to client?

just as topic

Look at MsgDeliverEvent. This would require that the client send a request to the driver (to let the driver know which connection to deliver the vent to) before the driver can deliver the event.

Or implement ionotify (which is MsgDeliverEvent). ionotify is part of the resource manager framework.


yes, i have used ionotify( e.g. a handle the messagge ,b kontrol the condition), but i can’t contrl a’s return value very vell, what should i do between a and b?

er, or how to send more inf? my means that e.g. the driver have four interrupt ( temp named 1,2.3,4)i want to send differentinfo represent different interruput in the routine which handle ionotify.

If you use ionotify and MsgDeliverEvent with a pulse, the pulse code could tell the client that the event is from the server and the server could then use the pulse value to indicate which interrupt the event is being delivered for (i.e. event.sigev_value.sival_int=1 for interrupt 1, event.sigev_value.sival_int=2 for interrupt 2, etc). This has the drawback of restricting you to using pulses (as opposed to signals or thread creation) with the sigevent structure though.

as above, if i use ionotify how can i test pulse value in client? select()? what shoud i do?

Thank you

ionotify() can do it, but i also use the select()'s timeout feature. what shoud i do?

I haven’t ever used select (I always use ionotify). You can still implement a timeout mechanism with ionotify (it’s a little more complicated though):

[code]#define IRQ_NOTIFICATION_CODE 0x10
#define IRQ_1_PULSE_VALUE 0x01
#define IRQ_2_PULSE_VALUE 0x02
#define IRQ_3_PULSE_VALUE 0x03

int WaitForIrqEvent(void)
int channelId=ChannelCreate(0);
int connectionId=ConnectAttach( 0, 0, channelId, _NTO_SIDE_CHANNEL, 0);
int irqId = 0;
struct sigevent notifyEvent;
struct _pulse irqPulse;
int replyId;
timer_t timerId;
struct itimerspec irqTimeout;

// Initialize the notification event to deliver a pulse
memset( &notifyEvent, 0, sizeof(notifyEvent));

// Setup a timer in order to detect timeouts
//  (10 million nsecs = .01 secs)
memset( &irqTimeout, 0, sizeof(irqTimeout));
irqTimeout.it_value.tv_sec = 0;
irqTimeout.it_value.tv_nsec = 10000000; 
timer_create( CLOCK_REALTIME, &notifyEvent, &timerId);

// Tell the server to notify you when an IRQ occurs
status = ionotify( fd, _NOTIFY_ACTION_POLLARM, _NOTIFY_COND_INPUT, &m_sockData);

// Start the timeout timer
timer_settime(timerId, 0, &irqTimeout, NULL);

// Loop until you get an IRQ pulse, a timeout pulse or something bad happens
while( irqId == 0)
    // Wait for a pulse to arrive
    replyId = MsgReceivePulse( channelId, &irqPulse, sizeof( irqPulse), NULL);
    if( replyId == -1)
        // an error occurred
        irqId = -1;
    else if( replyId == 0)
        // You got a legitimate pulse..hanlde it

        // Check if this is an IRQ notification pulse
        if( irqPulse.code == IRQ_NOTIFICATION_CODE)
            // Disarm the timeout timer
            irqTimeout.it_value.tv_nsec = 0; 
            timer_settime(timerId, 0, &irqTimeout, NULL);

            // See which event the driver is notifying you about
            switch( irqPulse.value.sival_int)
            case IRQ_1_PULSE_VALUE:
                // Driver is telling you that IRQ 1 occurred
            case IRQ_2_PULSE_VALUE:
                // Driver is telling you that IRQ 2 occurred
            case IRQ_3_PULSE_VALUE:
                // Driver is telling you that IRQ 3 occurred
            case IRQ_TIMEOUT_VALUE:
                // Our IRQ timeout timer with timeout
                irqId = irqPulse.value.sival_int;
                irqId = -1;

return( irqId);


in this line status = ionotify( fd, _NOTIFY_ACTION_POLLARM, _NOTIFY_COND_INPUT, &m_sockData);
m_sockdata shoud be notifyEvent?

i can’t return event from the function ( handle the ionotify), i should use MsgDeliverEvent?

Yes, m_sockData should be notifyEvent.
This sample was for the clientside code to implement a timeout for the ionotify, not the server that will actually deliver the event.