Shared memory locking
Shared memory locking
- Subject: Shared memory locking
- From: "Timothy J. Wood" <email@hidden>
- Date: Thu, 16 Jun 2005 22:51:52 -0700
I've seen this question go by a few times, but I don't think I've
seen an answer, or at least I can't find it in the archives.
I'm investigating reworking some code to use:
- shm_open for a database in a target process mappable by one or
more clients
- sem_open for the target to notify all clients of changes (each
client would need a thread waiting on the semaphore)
The missing bits are:
- a multi-process lock that has a _timed wait_ option
- some details on how to ensure that database "commits" to the
shared memory will be atomic wrt the locking
- Does msync() have any benefit over PPC sync before unlock,
isync after lock + whatever for Intel (it's been a few years... :)
Reviewing the Darwin 8.1 source, pthread_mutexattr_setpshared is
still not allowing for shared mutexes. Mach lock_set's don't seem to
have a timed wait.
About the only suggestion that seems likely to work is Chris
Kane's from 4 years ago (ancient history!) <http://lists.apple.com/
archives/darwin-development/2001/Mar/msg00372.html> (lwarx/stwcx +
semaphore + coding... bleah).
I can obviously implement my own timed-wait lock on top of the
primitives, but I'd rather not have to write & debug the code
myself. My needs are for very low latency locking in the target
process, so maybe I _should_ just implement my own...
-tim
_______________________________________________
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