Re: see if a mutex lock is taken?
Re: see if a mutex lock is taken?
- Subject: Re: see if a mutex lock is taken?
- From: Greg <email@hidden>
- Date: Mon, 11 Feb 2008 14:37:25 -0500
On Feb 10, 2008, at 10:26 PM, Michael Smith wrote:
The answer is meaningless unless you take the lock in the case where
it's not already owned; this is what the 'try' functions do.
If you really are just 'sniffing' the lock, call the 'try' function,
and if it returns success, release the lock. But I'd think long and
hard about what you think you can infer about anything just because
the lock wasn't held when you tried it. (If you're just
introspecting, then ignore the above caution.)
Which 'try' function? The only one I was able to find was in
lock_set.h (lock_try) which takes a lock_set_t, not a lck_mtx_t, and I
don't know if those can somehow be used together.
The only reason that I'm asking is because I was worried about having
parts of the kernel wait too long if another part is taking too long
to accomplish a task. Right now I think that it's alright if it does
wait, so I just have it take the lock, but I was curious if this
functionality existed in the kernel.
Thanks,
- Greg
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden