Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Jun 2007 15:50:53 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-hackers@freebsd.org
Cc:        hackers@freebsd.org, Artis Caune <Artis.Caune@latnet.lv>
Subject:   Re: stopping callouts
Message-ID:  <200706051550.54460.jhb@freebsd.org>
In-Reply-To: <4663DDD4.1020207@latnet.lv>
References:  <465FF29B.3010307@latnet.lv> <46604877.7030007@errno.com> <4663DDD4.1020207@latnet.lv>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 04 June 2007 05:39:32 am Artis Caune wrote:
> Sam Leffler wrote:
> > 
> > If you use callout_init_mtx then use callout_stop while holding my_mtx; 
> > if the callout is blocked waiting for my_mtx the request will be 
discarded.
> > 
> > callout_drain should not be called while holding my_mtx because it can 
> > sleep.
> > 
> 
> 
> Thanks,
> than I will use:
> 
> 
> MTX_LOCK;
> ...
> callout_stop();
> MTX_UNLOCK;

During module unload (or device detach) you should still do a callout_drain() 
before destroying the mutex, to make sure softclock() doesn't race with the 
mtx_destroy().

Thus:

foo_detach()
{

	FOO_LOCK(sc);
	foo_stop(sc);
	callout_stop(&sc->callout);
	FOO_UNLOCK(sc);

	bus_teardown_intr(...)

	bus_release_resources(...);

	callout_drain(&sc->callout);
	mtx_destroy(&sc->lock);
}

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706051550.54460.jhb>