| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Wally Crooze wrote:
> A couple of more things on locking/synchronization primitives...
>
> How effective are the implementations of funnels and other locking
> mechanisms (e.g. simple_locks) for SMP systems? I noticed that
> simple_lock is defined as either 1 (as funnels are in effect),
> disable_preemption (on Uni-processors) or usimple_lock (on SMP
> systems). I was under the impression that usimple_locks were for
> uni-processor systems... this is confusing.
OS X is always in "SMP" mode, even on UNI machines. This is because
the kernel is always compiled with pre-emption turned on. So simple
locks will act the same as on SMP machines.
> Also, can the locking and synchronization primitives be nested
> safely?
>
> i.e.
> simple_lock(lock1)
> simple_lock(lock2)
> simple_unlock(lock2)
> simple_unlock(lock1)
You can, but this kind of code can lead to deadlocks pretty easily.
You have to be careful.
> Does simple_locks disable interrupts, etc?
I can't remember if that is done for you, I always disable them
manually when needed.
> Also what interface is equivalent to synch-variables... such as
> sv_init, sv_rmproc?
Can't help you there.
> I'm also looking for a mechanism that will allow me to attempt to
> upgrade (i.e. read to write) an mrlock, but if it can't get it
> immediately it will return still holding the read (similar to the
> try versions of the other locks).
Have you looked at lock__bsd__ in <sys/lock.h>? It is based around
simple locks and supports read->write upgrades (I think). It may do
what you need.
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.