• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Shared memory locking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Darwin 8.0 on x86 and SMP (Dual CPU)
  • Next by Date: Communicating a memory entry between two unrelated processes
  • Previous by thread: Re: Real-time thread issue
  • Next by thread: Communicating a memory entry between two unrelated processes
  • Index(es):
    • Date
    • Thread