Re: Argument shmaddr in shmat()



On Dec 23, 2:48 pm, Don Morris <dgmor...@xxxxxxxxxxxxx> wrote:
Alex Vinokur wrote:
From man shmat
HP-UX 11i Version 2; August 2003

---------------------
void *shmat(int shmid, void *shmaddr, int shmflg);

      int shmdt(void *shmaddr);

[snip]
      If the shared memory segment has never been attached to by any
process prior to the current shmat() call, shmaddr must be specified
as zero and the segment is attached at a location selected by the
operating system.
[snip]

---------------------

Does it mean that if the only process works with the shared memory
segment, then shmaddr must be set 0 in shmat(), i.e.
shmat (shmat, 0, shmflg) ?

Well, you don't really say what you mean by "the only process works".
And I certainly hope you aren't using "int shmat;" as your shmid field
either...

Assuming what you mean is if this holds if only a single process creates
and attaches a shared memory segment -- yes, that single process still
passes 0 on the first attach [because the OS has already chosen a
shared virtual range for the object]. It is permitted if the process
does shmdt() and then shmat() again later for the process to pass 0
or the address previously given via the first shmat().

The big exception (since you cited the 11iv2 man page) is if this is
11iv2 on IPF -- there you can be running a process in MPAS layout.
MPAS processes may pass in any virtual address they want to shmat()
[if they want to put the segment somewhere in particular].

Don- Hide quoted text -

- Show quoted text -

So there's no way to map shared memory to a specific address on hpux?
.



Relevant Pages

  • Re: Argument shmaddr in shmat()
    ... void *shmat(int shmid, void *shmaddr, int shmflg); ... If the shared memory segment has never been attached to by any ... Does it mean that if the only process works with the shared memory ... segment, then shmaddr must be set 0 in shmat(), i.e. ...
    (comp.sys.hp.hpux)
  • A shared library which attaches a shared segment - whats the right way??
    ... I wrote a shared memory library in c++ which using 'shmget' and 'shmat' ... The varibale which attaches the shared memory segment using 'shmat' is ... both 'shmdt' and 'shmctl', or only 'shmctl'? ...
    (comp.unix.aix)
  • Problems accessing shared memory
    ... create or access the shared memory segment on a specific computer. ... The problem also appeared on a system using Windows 2003 server and Windows ... but we found a fix. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: A shared library which attaches a shared segment - whats the right way??
    ... > The varibale which attaches the shared memory segment using 'shmat' is ... In order to understand recursion you must first understand recursion. ...
    (comp.unix.aix)
  • Re: Quick questions on Shared Memory
    ... Andrew Falanga wrote: ... I finally got my shared memory program to work. ... > system destroys the shared memory segment. ... > Then a second program access the segment and reads the values. ...
    (comp.unix.programmer)