public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Implementing callback from driver to application
@ 2007-08-05 22:51 Mike Sweeney
  2007-08-06  2:12 ` Gary Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Sweeney @ 2007-08-05 22:51 UTC (permalink / raw)
  To: ecos-discuss

I have a custom device driver that needs to invoke a callback function
that is registered by the user's application. I have a 3 level
interrupt service mechanism within my device driver: an ISR, a DSR,
and an interrupt service thread. Basically in my interrupt service
thread I invoke the callback function. This is not a great design
because I don't want to be blocked in my interrupt service thread for
an unknown amount of time. I may have multiple application callbacks
to invoke depending on the device status.

I'm looking for some input on how best to tackle this within eCos. My
design requires the kernel so I can use any sort of kernel services
and am not restricting myself to the driver API. Should my driver have
another dedicated thread that receives mailbox messages from my
interrupt service thread and then calls the callbacks from within its
own context? All ideas are appreciated.

Thanks.

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ECOS] Implementing callback from driver to application
  2007-08-05 22:51 [ECOS] Implementing callback from driver to application Mike Sweeney
@ 2007-08-06  2:12 ` Gary Thomas
  2007-08-06  2:46   ` Mike Sweeney
  0 siblings, 1 reply; 3+ messages in thread
From: Gary Thomas @ 2007-08-06  2:12 UTC (permalink / raw)
  To: Mike Sweeney; +Cc: ecos-discuss

Mike Sweeney wrote:
> I have a custom device driver that needs to invoke a callback function
> that is registered by the user's application. I have a 3 level
> interrupt service mechanism within my device driver: an ISR, a DSR,
> and an interrupt service thread. Basically in my interrupt service
> thread I invoke the callback function. This is not a great design
> because I don't want to be blocked in my interrupt service thread for
> an unknown amount of time. I may have multiple application callbacks
> to invoke depending on the device status.
> 
> I'm looking for some input on how best to tackle this within eCos. My
> design requires the kernel so I can use any sort of kernel services
> and am not restricting myself to the driver API. Should my driver have
> another dedicated thread that receives mailbox messages from my
> interrupt service thread and then calls the callbacks from within its
> own context? All ideas are appreciated.

Yes, this is the preferred method (threads are quite cheap).
Your driver thread can then call back into the user code, block,
etc, without affecting the rest of the system.

Note: a good usage example of this is the input processing
thread in the FreeBSD networking stack.

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ECOS] Implementing callback from driver to application
  2007-08-06  2:12 ` Gary Thomas
@ 2007-08-06  2:46   ` Mike Sweeney
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Sweeney @ 2007-08-06  2:46 UTC (permalink / raw)
  To: ecos-discuss

On 8/5/07, Gary Thomas <gary@mlbassoc.com> wrote:
> Mike Sweeney wrote:
> > I have a custom device driver that needs to invoke a callback function
> > that is registered by the user's application. I have a 3 level
> > interrupt service mechanism within my device driver: an ISR, a DSR,
> > and an interrupt service thread. Basically in my interrupt service
> > thread I invoke the callback function. This is not a great design
> > because I don't want to be blocked in my interrupt service thread for
> > an unknown amount of time. I may have multiple application callbacks
> > to invoke depending on the device status.
> >
> > I'm looking for some input on how best to tackle this within eCos. My
> > design requires the kernel so I can use any sort of kernel services
> > and am not restricting myself to the driver API. Should my driver have
> > another dedicated thread that receives mailbox messages from my
> > interrupt service thread and then calls the callbacks from within its
> > own context? All ideas are appreciated.
>
> Yes, this is the preferred method (threads are quite cheap).
> Your driver thread can then call back into the user code, block,
> etc, without affecting the rest of the system.
>
> Note: a good usage example of this is the input processing
> thread in the FreeBSD networking stack.
>

Thanks Gary. I'll check out the code you mentioned.

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-06  2:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-05 22:51 [ECOS] Implementing callback from driver to application Mike Sweeney
2007-08-06  2:12 ` Gary Thomas
2007-08-06  2:46   ` Mike Sweeney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).