mapping SysV shared memory to data segment

mapping SysV shared memory to data segment

Post by R.Berrendor » Wed, 21 Jul 1993 21:49:39



Does anybody know a way to map a SysV shared memory segment into the data
segment thus overlapping the old mapping?

A straightforward approach would be:

    extern char buf[4096];

    /* get shared memory segment */
    if ((shm_id = shmget(IPC_PRIVATE, 4096, SHM_R | SHM_W)) == -1)
        return;

    /* map shared segment into data segemnt */
    if ((shm_addr = shmat(shm_id, buf, 0)) == -1)
        return;

but the call to shmat with an address in an existing region is not allowed (at
least not in SunOS, AIX and OSF1).

Any hints? Portable solutions based on Unix system calls preferred but OSF1 or
MACH3 specific calls would be ok.

Rudolf.

-------------------------------------------------------------------------------
Rudolf Berrendorf                           Phone: +49 (2461) 61-6589
Zentralinstitut fuer Angewandte Mathematik  Fax  : +49 (2461) 61-6656

D-52425 Juelich, Germany
-------------------------------------------------------------------------------