Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trylocks in the kernel



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:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.