

shmget()               COHERENT System Call              shmget()




Get shared-memory segment

#include <sys/shm.h>
sshhmmggeett(_k_e_y, _s_i_z_e, _s_h_m_f_l_g)
kkeeyy_tt _k_e_y; iinntt _s_i_z_e, _s_h_m_f_l_g;

shmget returns the shared-memory identifier associated with key.

A  shared-memory  identifier and  associated  data structure  and
shared memory  segment of size  size bytes is created  for key if
key does  not already have a  shared-memory identifier associated
with it, and (_s_h_m_f_l_g & IIPPCC_CCRREEAATT) is true.

Upon creation, the  data structure associated with the new shared
memory identifier is initialized as follows:

*  shm_perm.cuid,  shm_perm.uid, shm_perm.cgid,  and shm_perm.gid
   are set equal to the effective user ID and effective group ID,
   respectively, of the calling process.

*  The low-order nine bits  of shm_perm.mode are set equal to the
   low-order nine bits  of shmflg.  These nine bits define access
   permissions: the  top three bits give  the owner's access per-
   missions  (read, write,  execute), the  middle three  bits the
   owning group's access  permissions, and the low three bits ac-
   cess permissions for others.

*  shm_segsz is set equal to the value of size.

*  shm_lpid,  shm_nattch, shm_atime, and shm_dtime  are set equal
   to zero.  shm_ctime is set equal to the current time.

shmget fails if any of the following is true:

*  size  is less than the system-imposed  minimum or greater than
   the system-imposed maximum.  shmget sets errno to EINVAL.

*  A  shared-memory identifier exists for  key but operation per-
   mission  as specified  by the  low-order  nine bits  of shmflg
   would not be granted (EEAACCCCEESS).

*  A shared-memory identifier exists  for key but the size of the
   segment associated  with it is less than size  and size is not
   equal to zero (EEIINNVVAALL).

*  A shared-memory identifier  does not exist for key and (_s_h_m_f_l_g
   & IIPPCC_CCRREEAATT) is false (EENNOOEENNTT).

*  A shared-memory identifier is to be created but the system-im-
   posed  limit on  the maximum number  of allowed  shared memory
   identifiers system-wide would be exceeded (EENNOOSSPPCC).

*  A  shared-memory identifier and  associated shared-memory seg-
   ment are  to be created, but the  amount of available physical


COHERENT Lexicon                                           Page 1




shmget()               COHERENT System Call              shmget()



   memory is not sufficient to fill the request (EENNOOMMEEMM).

*   A shared-memory  identifier exists  for key  but (  (_s_h_m_f_l_g &
   IIPPCC_CCRREEAATT) && (_s_h_m_f_l_g & IIPPCC_EEXXCCLL) ) is true (EEEEXXIISSTT).

***** Return Value *****

Upon successful completion,  shmget returns a shared-memory iden-
tifier, which  is always  a non-negative integer.   Otherwise, it
returns -1 and sets eerrrrnnoo to an appropriate value.

***** Files *****

/usr/include/sys/ipc.h
/usr/include/sys/shm.h
/dev/shm
/drv/shm

***** See Also *****

COHERENT system calls, shm, shmctl()

***** Notes *****

To  improve  portability,  the  COHERENT  system  implements  its
shared-memory  functions as  a device  driver rather  than actual
system calls.






























COHERENT Lexicon                                           Page 2


