await & asleep

Daniel Eischen deischen at freebsd.org
Wed Jul 27 17:25:25 GMT 2005


On Wed, 27 Jul 2005, Scott Long wrote:

> Daniel Eischen wrote:
>
> >
> > My mistake then.  I thought they were deprecated when mutex and
> > CVs were introduced.  There is no need for them except for compatability,
>
> Incorrect.  A mutex is not a replacement for sleep.  CV's and semaphores
> implement some of what tsleep does, but tsleep is absolutely appropriate
> when you want to sleep for an event (like disk i/o completing) and don't
> need to worry about mutexes.  Not every inch of the kernel needs to be
> covered by mutexes, Giant or otherwise.

Traditionally, you did splXXX() then tsleep().  But splXXX() has been
deprecated and you need to use mutexes for protection.  If you are going
to sleep for an event, that is cv_wait() and friends and you use the
mutex for protection.  It's hard to imagine that queueing disk I/O
requests and their completions don't need mutexes (or lockmgr?) for
protection, but I'll take your word for it.

-- 
DE



More information about the freebsd-hackers mailing list