On Sun, Dec 11, 2016 at 11:13:47AM -0800, Sterling Hughes wrote:
> Hi,
> 
> As a part of developing the sensor interface, I want to register a 
> “listener” on the event queue:
> 
>      listener.sl_sensor_type = type;
>      listener.sl_func = sensor_shell_read_listener;
>      listener.sl_arg = &ctx;
> 
>      rc = sensor_register_listener(sensor, &listener);
>      if (rc != 0) {
>          goto err;
>      }
> 
> And then I want to essentially “wait” until I’ve read ’n’ 
> entries, and block in my task:
> 
> 
>      /* Block until we've read 'n' samples. */
>      while (ctx.num_entries < nsamples) {
>          os_eventq_run(sensor_mgr_evq_get());
>          os_time_delay(1);
>      }
> 
> The sensor_shell_read_listener() function updates “num_entries”, and 
> when I’ve read the desired number of samples, the loop finishes.
> 
> Just calling os_time_delay() or os_eventq_run() in and of themselves is 
> not sufficient:
> 
> - os_eventq_run() will let the current task’s events (default event 
> queue in this case) run, but won’t process other tasks events (e.g. 
> shell is run out of a separate task in this case.)

Sorry if I'm being dense here, but there is something I am missing.  Why
won't other tasks run while you block on the sensor event queue?  This
should only be an issue if the event queue is never empty, right?  Are
you expecting this eventq to be receiving events faster than you can
deqeueue them or something?

> - os_time_delay() lets the other tasks run.
> 
> q: Should we add a os_eventq_yield(evq, time) function that does both of 
> these tasks?  I think it might be clearer that this is the intention in 
> that case.


Reply via email to