Re: SHM_INFO and SHM_STAT
Re: SHM_INFO and SHM_STAT
- Subject: Re: SHM_INFO and SHM_STAT
- From: Christof Rath <email@hidden>
- Date: Wed, 2 Apr 2008 12:33:16 +0200
Hello Terry (and the rest of you),
I sent your notes to the lead programmer of the framework I try to
compile and got a reply that I would love to forward to you:
Use standard APIs instead:
<http://www.opengroup.org/onlinepubs/009695399/functions/shmctl.html>
?
SHM_INFO you can emulate by writing code to popen the "ipcs"
command. You are better off using ftok(0 to identify a shared
memory segment key specifically, rather than trying to figure out
the next available one.
It's pretty bad that the ipcs code is not available to use the API
that this program uses directly. What we are trying to do is enumerate
all existing shared memory segment for peeking into them to see if we
find our own shared memory segments.
SHM_STAT does not appear to be a useful API, since it only returns
an array index, and that array index could in no way be useful to
you directly, since you can't access the array which is being
indexed by the number which would be returned.
Wrong. It is helpful for the mentioned enumeration. For IPC_STAT you
need a shmem ID, for SHM_STAT you can use the kernel-internal array
index and you can get the length of the array with SHM_INFO and thus
you can iterate really smoothly over all existing shared memory
segments. This code works on FreeBSD as well which makes it especially
cumbersome that Apple left this part of useful code out.
SHM_LOCK/SHM_UNLOCK are really dangerous, since you are asking that
the memory region be wired down. You can ask for this via the
standard interfaces mlock() and munlock(). Typically, this is a bad
idea. Wiring down physical memory is constrained by administrative
limits which can not be bypassed, so if you ask for too much, you
will get none. These interfaces work equally well in Linux, and are
more portable.
True, but there are situation when you need it in a real-time robotics
domain were you cannot afford if your critical data section has been
swapped away...
All I need is the ipcs source or a note on how this program enumerates
all existing shared memory segments.
Tim
and Christof
_______________________________________________
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