Trylocks in the kernel
Trylocks in the kernel
- Subject: Trylocks in the kernel
- From: Ryan McGann <email@hidden>
- Date: Mon, 12 Dec 2005 22:23:03 -0800
The new Tiger locking KPIs seem to lack a trylock variant for any of
the lock types (mutex, spinlock, read/write). I'm trying to figure
out how to get around this. I need to take a read-write lock in a
socket filter dataIn callback, but of course you cannot block inside
dataIn for any length of time. So I _was_ going to use a trylock, and
if I failed to get the lock, just bail out. But it looks like the
only way to accomplish what I want to do is to use
lck_rw_sleep_deadline.
However I'm not exactly sure of the semantics of this API. If I give
it a deadline of "now", will it still perform a context switch
regardless of whether the lock is taken or not? I don't want the
expense of a context switch if the lock isn't even going to be taken.
Is there any way of duplicating the behavior of a trylock using the
Tiger KPIs? Or am I stuck using lck_rw_sleep_deadline? And can that
API context switch on me without taking the lock?
Thanks,
Ryan
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden