[comp.unix.questions] shared memory segment, shmat

ycy@walt.cc.utexas.edu (Joseph Yip) (07/27/90)

A few days ago, I came across some code that uses shmat() and related
functions. The program maps a file using shmat() (we are using IBM RT,
running AIX 2.2.1). Basically, the program opens an binary digital image
file and maps it. Can someone explain to me what is shared memory
segment and how to use it? In /usr/include/sys/shm.h (AIX), SHM_MAP flag
maps a file instead of share segment. But in SunOS 4.0, shm.h does not
have this flag. How can I map a file in this case?

Thank you.

- Joseph Yip
Email: joseph@zeus.ee.utexas.edu

guy@auspex.auspex.com (Guy Harris) (07/29/90)

>A few days ago, I came across some code that uses shmat() and related
>functions. The program maps a file using shmat() (we are using IBM RT,
>running AIX 2.2.1). Basically, the program opens an binary digital image
>file and maps it. Can someone explain to me what is shared memory
>segment and how to use it? In /usr/include/sys/shm.h (AIX), SHM_MAP flag
>maps a file instead of share segment. But in SunOS 4.0, shm.h does not
>have this flag. How can I map a file in this case?

By using the "mmap()" call; see MMAP(2).

IBM chose to use "shmat()" to map files; Sun chose to use a modified
version of the proposed-but-never-implemented-by-Berkeley "mmap()" call.
Other vendors have implemented "mmap()" as well (Convex and Sequent are,
I think, among them); the Sun implementation is the basis of the System
V Release 4 implementation, and its interface is also planned to be used
by Berkeley in 4.4BSD.  I think it'll be in OSF/1 as well.

net@tub.UUCP (Oliver Laumann) (07/29/90)

In article <3783@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes:
> 
> IBM chose to use "shmat()" to map files; Sun chose to use a modified
> version of the proposed-but-never-implemented-by-Berkeley "mmap()" call.

While we're at it-- does there exist a version of UNIX that supports
the proposed-but-never-implemented-by-Berkeley "portal()" system call?
Is it in 4.3reno, or will it be implemented by 4.4BSD?  SunOS 5.0?

Regards,
--
Oliver Laumann     net@TUB.BITNET     net@tub.cs.tu-berlin.de     net@tub.UUCP