Paul Durrant wrote:
On 29/05/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Paul Durrant wrote:
> On 28/05/07, Garrett D'Amore <[EMAIL PROTECTED]> wrote:
>> You should not attempt to acquire a lock which will be held by other
>> functions calling cv_wait, or its brethren. (There are ways to do that
>> safely, but it requires a fair bit of effort to make sure you do it
>> safely.)
>>
>
> I was not aware of this restriction, nor can I find it documented.
> This suggests that one cannot call cv_signal() from within an
> interrupt handler. Is this true?
>
>  Paul
>
Check the man page for cv_wait(9f) under CONTEXT.

Yes, I am aware of the restriction for cv_wait(). That makes sense.

 As for using cv_signal
in an interrupt handler, no problem.  Initially, at least, this was the
most common place for
cv_signal to be called.


But to call cv_signal() one must be holding the mutex that was
released by the call to cv_wait() in the other thread; thereby doing
something that Garrett suggests is unsafe.

Hmmm...

If the mutex that is being acquired is passed to cv_wait, then cv_wait is not specifically sleeping holding that mutex (because it atomically releases the mutex before sleeping.)

So that mutex would be safe, unless it is held across other calls to cv_wait where it is _not_ passed as the mutex argument for cv_wait.

   -- Garrett


 Paul


_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to