Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/netinet



On Wed Aug 11 2010 at 14:22:40 +0300, Jukka Ruohonen wrote:
> On Wed, Aug 11, 2010 at 09:36:45AM +0000, Antti Kantee wrote:
> > Module Name:        src
> > Committed By:       pooka
> > Date:               Wed Aug 11 09:36:45 UTC 2010
> > 
> > Modified Files:
> >     src/sys/netinet: ip_carp.c
> > 
> > Log Message:
> > Use kpause() instead of DELAY() and sleep a minimum of 1 tick.
> > This is possible now since softints have a thread context.  It's
> > also not a very frequent code path.  Addresses ABI issue with delay
> > (kern/40505).
> 
> Could you or someone else briefly note what is the main difference between
> DELAY(9) and kpause(9) when used like this? In what scenarios kpause(9) is
> preferable?

delay is a busyloop while kpause yields.  You cannot use the latter
without thread context (i.e. in a hard interrupt).  delay is not really
preferrable, but if *must* use it: a) when you don't have thread context
b) if you're doing something performance/timing critical and can't afford
the jitter and inaccuracy from a sleep.

... hmm, looking at the man page (delay(9)), it says the same:

     The delay is implemented as a machine loop, preventing events other than
     interrupt handlers for unmasked interrupts to run.  DELAY() is reentrant
     (doesn't modify any global kernel or machine state) and is safe to use in
     interrupt or process context.

     For long delays, condition variables should be considered, however they
     can only be used from process context and their resolution is limited by
     the system clock frequency.

rtfm ;) ;)

(although I guess the point about nothing being able to run is not true
anymore with kernel preemption)


Home | Main Index | Thread Index | Old Index