Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ () — Coherent 3.1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


shmget()               COHERENT System Call              shmget()




Get shared-memory segment

#include <sys/shm.h>
shmget(key, size, shmflg)
key_t key; int size, shmflg;

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 (shmflg & IPC_CREAT) 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 (EACCES).

*  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 (EINVAL).

*  A shared-memory identifier  does not exist for key and (shmflg
   & IPC_CREAT) is false (ENOENT).

*  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 (ENOSPC).

*  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 (ENOMEM).

*   A shared-memory  identifier exists  for key  but (  (shmflg &
   IPC_CREAT) && (shmflg & IPC_EXCL) ) is true (EEXIST).

***** 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 errno 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


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026