Darn, you're right. I'm writing these emails from my phone, and I didn't
look at the code closely enough.  For other packages, the start event
only gets executed the first time the event queue gets used (as you
said).  I guess it has worked out in practice because the application
uses the package shortly after the OS starts.

That's not so great.  Second stage initialization sounds good to me.
Alternatively, the system could keep track of packages that need an
event queue, and enqueue their start event when a default event queue is
set.  Earlier, we discussed using linker sections to accomplish this
without requiring any RAM. I looked into this, but concluded it wasn't
possible without modifying the linker scripts.

Chris

On Sat, Dec 10, 2016 at 12:30:39PM -0800, Sterling Hughes wrote:
> How do you assign an event queue if you are relying on the default event 
> queue being there?  
> 
> Can you point me to an example of where this is done? 
> 
> Sterling 
> 
> > On Dec 10, 2016, at 12:08 PM, Christopher Collins <ccoll...@apache.org> 
> > wrote:
> > 
> > The way other packages handle this is they enqueue the startup event
> > when their event queue is assigned.  This happens automatically when you
> > call os_eventq_designate(); the last parameter is the event to enqueue
> > immediately.
> > 
> > Chris
> > 
> >> On Sat, Dec 10, 2016 at 11:30:27AM -0800, Sterling Hughes wrote:
> >> Hi,
> >> 
> >> I’m looking at using the default eventq (or allowing for it), in a 
> >> library I’m working on.  In order to do that, I have a function:
> >> 
> >> static struct os_eventq *
> >> sensor_mgr_evq_get(void)
> >> {
> >>     os_eventq_ensure(&sensor_mgr.mgr_eventq, NULL);
> >> 
> >>     return (sensor_mgr.mgr_eventq);
> >> }
> >> 
> >> And this function gets called within my package’s sysinit, as I want 
> >> to schedule a callout to run this function immediately on bootup:
> >> 
> >>     /**
> >>      * Initialize sensor polling callout and set it to fire on boot.
> >>      */
> >>     os_callout_init(&sensor_mgr.mgr_wakeup_callout, 
> >> sensor_mgr_evq_get(),
> >>             sensor_mgr_wakeup_event, NULL);
> >>     os_callout_reset(&sensor_mgr.mgr_wakeup_callout, 0);
> >> 
> >> The problem is that the default event queue is not setup until after 
> >> sysinit executes, as task setup is later on.
> >> 
> >> What is the right way to do this?  For now, I can move the 
> >> initialization from sysinit and to the main() function at task level, 
> >> however, I don’t think this is how we want to manage initialization 
> >> over time.  We probably need some way for a package to have a system 
> >> initialization stage that runs after the OS has started, and the default 
> >> event queue has been set.
> >> 
> >> Cheers,
> >> 
> >> Sterling

Reply via email to