resource manager & pulse

Hi,

I have question, about resource manager and incoming pulse from ISR.
I’m writing driver for pci card, and the cards has associated one irq for
more actions.


/* frame of resource manager */
dpp = dispatch_create();
tpp = thread_pool_create());
iofunc_func_init();
iofunc_attr_init();
attach_path_to_pathname();
event.sigev_code = pulse_attach(dpp, MSG_FLAG_ALLOC_PULSE,
0, &pulse_handler,
NULL));
event.sigev_notify = SIGEV_PULSE;
event.sigev_priority = EVENT_PRIORITY;
event.sigev_value.sival_int = IRQ_PULSE_EVTVAL;
event.sigev_coid = message_connect(dpp, MSG_FLAG_SIDE_CHANNEL);
thread_pool_start(tpp);

Every (20ms) occurs irq, and I do in ISR: “return (&event);”.
I have also special case, that occurs only rarely, described bellow.

int pulse_handler(message_context_t *ctp, int code, unsigned flags, void
*handle)
{
//… every 20ms I do some useful stuff

// special case
if()
{
for(idx = 0; idx < 3; idx++)
{
*pcicardreg = val + idx;
// this causes irq during 2mikro sec and in ISR I
“return (&event);”
MsgReceivePulse(chid, &pulse, sizeof(pulse),
NULL);
^^^^
/ / !! QUESTION !! is it possible to receive
event here? and not to
// create another channel, establish a
connection, and for the special
// case returned another “event1”, where I find
the chid?
}
}
}

I temporary resolve it, that I create another channel, establish a
connection,
and for the special case I return another pulse “event1”.
chid1 = ChannelCreate();
event1.sigev_coid = ConnectAttach(ND_LOCAL_NODE, 0, chid1, 0, 0));

I think, that it must be possible to do via channel and connection that
creates
Resource manager (above).

Can You help me?
Thanks ales.

David Brdicka <dbrdicka@retia.cz> wrote:

Hi,

I have question, about resource manager and incoming pulse from ISR.
I’m writing driver for pci card, and the cards has associated one irq for
more actions.



/* frame of resource manager */
dpp = dispatch_create();
tpp = thread_pool_create());
iofunc_func_init();
iofunc_attr_init();
attach_path_to_pathname();
event.sigev_code = pulse_attach(dpp, MSG_FLAG_ALLOC_PULSE,
0, &pulse_handler,
NULL));
event.sigev_notify = SIGEV_PULSE;
event.sigev_priority = EVENT_PRIORITY;
event.sigev_value.sival_int = IRQ_PULSE_EVTVAL;
event.sigev_coid = message_connect(dpp, MSG_FLAG_SIDE_CHANNEL);
thread_pool_start(tpp);

Every (20ms) occurs irq, and I do in ISR: “return (&event);”.
I have also special case, that occurs only rarely, described bellow.

int pulse_handler(message_context_t *ctp, int code, unsigned flags, void
*handle)
{
//… every 20ms I do some useful stuff

// special case
if()
{
for(idx = 0; idx < 3; idx++)
{
*pcicardreg = val + idx;
// this causes irq during 2mikro sec and in ISR I
“return (&event);”
MsgReceivePulse(chid, &pulse, sizeof(pulse),
NULL);
^^^^
/ / !! QUESTION !! is it possible to receive
event here? and not to
// create another channel, establish a
connection, and for the special
// case returned another “event1”, where I find
the chid?
}
}
}

I temporary resolve it, that I create another channel, establish a
connection,
and for the special case I return another pulse “event1”.
chid1 = ChannelCreate();
event1.sigev_coid = ConnectAttach(ND_LOCAL_NODE, 0, chid1, 0, 0));

I think, that it must be possible to do via channel and connection that
creates Resource manager (above).

If I understand you correctly you want to do another
MsgReceivePulse() in your pulse handler and then
based on that fire off another event to the same
channel instead of creating a new channel.

If that is right then yes you can do that by using
the message_connect() again for event1 and send
it off.

Note that it is “odd” that you would do a MsgReceivePulse
in this pulse_handler() since if you were multi-threaded
you wouldn’t have any guarantee that some other thread
wouldn’t have already processed/received the pulse.
Perhaps this isn’t the case with your design, but something
to watch for.

Thomas

Thomas (toe-mah) Fletcher QNX Software Systems
thomasf@qnx.com Neutrino Development Group
(613)-591-0931 http://www.qnx.com/~thomasf

<thomasf@qnx.com> pí¹e v diskusním pøíspìvku:9g541b$t5q$1@nntp.qnx.com

David Brdicka <> dbrdicka@retia.cz> > wrote:
Hi,

I have question, about resource manager and incoming pulse from ISR.
I’m writing driver for pci card, and the cards has associated one irq
for
more actions.


/* frame of resource manager */
dpp = dispatch_create();
tpp = thread_pool_create());
iofunc_func_init();
iofunc_attr_init();
attach_path_to_pathname();
event.sigev_code = pulse_attach(dpp, MSG_FLAG_ALLOC_PULSE,
0,
&pulse_handler,
NULL));
event.sigev_notify = SIGEV_PULSE;
event.sigev_priority = EVENT_PRIORITY;
event.sigev_value.sival_int = IRQ_PULSE_EVTVAL;
event.sigev_coid = message_connect(dpp, MSG_FLAG_SIDE_CHANNEL);
thread_pool_start(tpp);

Every (20ms) occurs irq, and I do in ISR: “return (&event);”.
I have also special case, that occurs only rarely, described bellow.

int pulse_handler(message_context_t *ctp, int code, unsigned flags,
void
*handle)
{
//… every 20ms I do some useful stuff

// special case
if()
{
for(idx = 0; idx < 3; idx++)
{
*pcicardreg = val + idx;
// this causes irq during 2mikro sec and in
ISR I
“return (&event);”
MsgReceivePulse(chid, &pulse, sizeof(pulse),
NULL);
^^^^
/ / !! QUESTION !! is it possible to receive
event here? and not to
// create another channel, establish a
connection, and for the special
// case returned another “event1”, where I
find
the chid?
}
}
}

I temporary resolve it, that I create another channel, establish a
connection,
and for the special case I return another pulse “event1”.
chid1 = ChannelCreate();
event1.sigev_coid = ConnectAttach(ND_LOCAL_NODE, 0, chid1, 0, 0));

I think, that it must be possible to do via channel and connection that
creates Resource manager (above).


If I understand you correctly you want to do another
MsgReceivePulse() in your pulse handler and then
based on that fire off another event to the same

based on that fire off not another event, but the same event (“event”) to
the same

channel instead of creating a new channel.

My idea is that I will have two receive function. First receive function is
(from my opinion) in body of thread_poll_start() function, and second
receive function (MsgReceivePulse()) is in pulse_handler. And now I want to
receive still the same “event” from ISR, but only on various places

If that is right then yes you can do that by using
the message_connect() again for event1 and send
it off.

In this solution I have one channel, that is created by resource manger
(but I still don’t know its “chid”) and two events (“event”, and “event1”).
Question is, where I find “chid”, that is needed by fce MsgReceivePulse() if
I don’t want to use second channel (chid1 = ChannelCreate():wink:

Note that it is “odd” that you would do a MsgReceivePulse
in this pulse_handler() since if you were multi-threaded
you wouldn’t have any guarantee that some other thread
wouldn’t have already processed/received the pulse.
Perhaps this isn’t the case with your design, but something
to watch for.

At the beginning (3 weeks ago), I used the function for multi thread
resource manager, but week ago I decided, use only one thread, also I
set
pool_attr.lo_water = 0;
pool_attr.hi_water = 1;
pool_attr.increment = 0;
pool_attr.maximum = 1;
and want to use resmgr_context_alloc() for single thread.

Thomas

Thomas (toe-mah) Fletcher QNX Software Systems
thomasf@qnx.com > Neutrino Development Group
(613)-591-0931 > http://www.qnx.com/~thomasf