Re: stopping callouts



On Friday 01 June 2007 12:19, Artis Caune wrote:
Hello FreeBSD-hackers!

what is the right way to stop callout which is initialized with mutex:
callout_init_mtx(&callout_function, &my_mtx, 0);

should I lock mutex before calling callout_drain() or not?

man page says: callout_drain() is identical to callout_stop() and
if the callout has an associated mutex, then that mutex must be held
when callout_stop() is called.


You should call "callout_drain()" w/o any locks held, because this function
might sleep.

callout_drain() is not identical to callout_stop(). Then man-page should be
updated.

--HPS
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Simpler SMP-friendly callout/timeout semantics
    ... The current callout/timeout API supports Giant-locked and MP-safe ... A summary of the difficulties faced when using the current callout ... was to supply a mutex when the callout is created and have ... +static int avg_mtxcalls; ...
    (freebsd-arch)
  • timeout(9), mutexes, and races
    ... so we always try to acquire Giant here. ... Would the solution be to try to detect this condition (callout ... of knowing what mutex it would be... ... Or is there another way to solve this somehow? ...
    (freebsd-hackers)
  • Re: stopping callouts
    ... what is the right way to stop callout which is initialized with mutex: ... should I lock mutex before calling callout_drainor not? ... if the callout has an associated mutex, then that mutex must be held when callout_stopis called. ...
    (freebsd-hackers)
  • Re: periodically save current time to time-of-day hardware
    ... it does a trylock on the RTC mutex. ... If it grabs the mutex then ... I would dispense with the kthread and just use a callout (or have a callout ...
    (freebsd-hackers)
  • Re: periodically save current time to time-of-day hardware
    ... it does a trylock on the RTC mutex. ... If it grabs the mutex then ... I would dispense with the kthread and just use a callout (or have a callout ...
    (freebsd-hackers)