On Thu, 15 Mar 2001, Dawson Engler wrote:
>       2.  And, unrelated:  given the current locking discipline, is
>       it bad to hold any type of lock (not just a spin lock) when you
>       call a potentially blocking function?  (It at least seems bad
>       for performance, since you'll hold the lock for milliseconds.)

In general, yes.  The lock may be held for much longer than milliseconds
if the potentially blocking function is waiting for I/O from a network,
or a terminal, potentially causing all threads to block on the lock
until someone presses a key, in this extreme example.  If the lock is a
spinlock, then complete deadlock can occur.

You're probably aware that semaphores are used both as blocking mutex
locks, where the down (lock) and up (unlock) calls are made by the same
thread to protect critical data, and as a synchronization mechanism,
where the down and up calls are made by different threads.   The former
use is a "lock", while the latter down() use is a "potentially blocking
function" in terms of your question.  I don't know how easy it would be
for your analysis tools to distinguish between them.

Nigel Gamble                                    [EMAIL PROTECTED]
Mountain View, CA, USA.                         http://www.nrg.org/

MontaVista Software                             [EMAIL PROTECTED]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to