
Signature
-------------------------------------------------------------------
Bob Freeman
Experience Technology Inc.
(905)-383-7086 Cell: (905)-517-4966
> The Apple developer site has a shared memory sample app, using the SHM Unix
> modules, written in Objective C, under Cocoa. I want to implement shared
> memory under C++/Mach-o.... do I need to start from scratch or can I somehow
> port the sample app over... any direction, tips, comments would be most
> appreciated.....
There's a word for people who reference stuff like this and don't include
URL's ; )
I presume you mean
http://developer.apple.com/samplecode/SharedMemory/listing3.html ?
Looking over it, it appears that shmget and the semaphore stuff are pure C
API's being used in a Cocoa program. You'll have to convert NSThread to
another type (depending on what you're doing, but you'll have to do that
anyway.)
Otherwise, get rid of all the Objective-C UI code and translate a few things
(the NSString stuff in sem_open), and you'll be off to a good start. If you
don't do Objective-C, spend an hour or two with Apple's Intro PDF and you'll
be ready for the next time.
While searching, I also came across (in tech note 2071 about porting command
line tools):
shmget
This API is supported but its use is not recommended. shmget has a limited
memory blocks allocation. When several applications use shmget, this limit
may change and cause problems for the other applications. We recommend the
use of mmap for file mapping into memory.
This may not apply to you and/or mmap may not be appropriate, but be aware
of it.