Re: Compiling C++ modules

Avi Kivity
2006-04-25T18:26:56Z

Valdis.Kletnieks@vt.edu wrote:
>
> On Tue, 25 Apr 2006 20:53:01 +0300, Avi Kivity said:
>
> > Additionally, C++ guarantees that if an exception is thrown after
> > spin_lock() is called, then the spin_unlock() will also be called.
> > That's an interesting mechanism by itself.
>
> Gaak. So let me get this straight - We lock something, then we hit
> an exception because something corrupted the lock. Then we *unlock* it
> so more code can trip over it.
>
> Sometimes the correct semantic is to *leave it locked*.
>
C++ doesn't force *any* semantic on you. It gives you tools to implement
the semantic you want. If you want the lock to remain unlocked, that is
of course doable.

Most often (almost always), the cause of the exception is not random
corruption, but an error (I/O error, out of memory, etc.) and you want
to unlock the lock. C++ helps you get it right without writing tons of
boilerplate code:

[avi@cleopatra linux]$ grep -r out.*: . | wc -l
10446

How many times you want it unlocked but it's left locked because of an
obscure error path? When does 2.6.16.14 come out?

--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.