Detlef Vollmann wrote:
 > Gilles Chanteperdrix wrote:
 > > You can even do this in __ipipe_mach_set_dec, this avoid the need to
 > > modify I-ipipe non-machine specific code. Something like:
 > > 
 > > void __ipipe_mach_set_dec(unsigned long delay)
 > > {
 > >     if (delay < 8)
 > >         ipipe_trigger_irq(__ipipe_mach_timerint);
 > >     else
 > >         OSMR0 = OSCR + delay;
 > > }
 > 
 > Thanks, ipipe_trigger_irq() is exactly what I was looking for.
 > 
 > I'll just add another test after the update of OSMR0 for the
 > case that we got interrupted between the comparison and the
 > assignment.  And in that (probably very rare) case I accept that
 > I loose a timer tick :-(

I do not see what you mean. "delay" value does not change over time.

 > 
 > Also, this way the timer comes a bit early, so any handler that
 > checks the TSC might think that this is the wrong interrupt --
 > and wait forever for the correct one.
 > But the only other option would be the busy wait...

It will work for Xenomai:
- in periodic mode, each interrupt is treated as a tick
- in aperiodic mode, there are two guards; first the tsc is compared to
  the next software timer expiration date using nkschedlat as a margin;
  second, if the tick is so early that there is no software timer
  expiration to  handle, no software timer will be dequeued and the next
  software timer expiration date will be reused to reprogram the
  hardware timer.

 > 
 > The question about recursion remains:
 > If a domain decides in its timer interrupt handler to reprogram
 > the timer by calling __ipipe_mach_set_dec() (indirectly), and
 > we already are too close to the next match, then that interrupt
 > handler is called recursively.
 > Is every ipipe domain expected to cope with this?

As explained above, this recursion can only happen for a limited time
(in the worst case, if nkschedlat is 0, during 8 hardware timer ticks).
Keep in mind that these functions are called with interrupts off, so the
"recursion", is serialized.

You should really have a look at ksrc/nucleus/timer.c, functions
do_tick_aperiodic and do_tick_periodic. 

-- 


                                            Gilles Chanteperdrix.

_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to