Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
shmget(2)		      System Calls Manual		     shmget(2)

NAME
       shmget -	get shared memory segment

SYNOPSIS
DESCRIPTION
       returns the shared memory identifier associated with key.

       A  shared  memory  identifier  and associated data structure and	shared
       memory segment of size size bytes (see glossary(9)) are created for key
       if one of the following is true:

	      o	 key  is  equal	to This	call creates a new identifier, subject
		 to available resources.  The identifier  will	never  be  re-
		 turned	 by  another  call  to until it	has been released by a
		 call to The identifier	 should	 be  used  among  the  calling
		 process  and  its  descendents; however, it is	not a require-
		 ment.	The resource can be accessed by	any process having the
		 proper	permissions.

	      o	 key  does not already have a shared memory identifier associ-
		 ated with it, and (shmflg & is	``true''.  If is set in	shmflg
		 the  shared memory segment created can	only be	shared by pro-
		 cesses	of the same executable type. That is,  an  application
		 compiled  as  a 32-bit	process	will be	able to	share the same
		 memory	segment	with other 32-bit processes, and  an  applica-
		 tion  compiled	 as a 64-bit process will be able to share the
		 same memory segment with other	64-bit processes. If a	64-bit
		 bit process wants to create a shared memory segment which can
		 also be shared	with 32-bit processes, the 64-bit process must
		 specify  in  addition	to in shmflg.  The 32-bit process does
		 not need to specify

       On HP Scalable Computing	Architecture (SCA) systems with	 multiple  lo-
       cality  domains,	specifying in shmflag targets the shared memory	to the
       locality	on which the allocating	thread is executing at the time	of the
       call.   This  overrides the default allocation policy of	"first touch",
       in which	memory is allocated from the  locality	domain	on  which  the
       thread is executing at the time of the fault. When is specified:

	      o	 Should	 there not be enough memory available in the specified
		 locality domain to satisfy the	request, memory	 is  allocated
		 from the domain on which the thread is	currently executing.

	      o	 On systems with a single locality domain, the call has	no ef-
		 fect.

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

	      o	 and  are  set	equal  to  the effective user ID and effective
		 group ID, respectively, of the	calling	process.

	      o	 the low-order 9 bits of are set equal to the low-order	9 bits
		 of shmflg.  is	set equal to the value of size.

	      o	 and are set equal to 0.

	      o	 is set	equal to the current time.

       Specifying  in a	call to	along with forces the shared memory segment to
       be allocated from the global quadrant and not from the local quadrants.
       If  this	 is not	possible, will fail.  Please refer to setmemwindow(1M)
       for more	information.

EXAMPLES
       The following call to returns a unique  shmid  for  the	newly  created
       shared memory segment of	4096 bytes:

RETURN VALUE
       Upon  successful	 completion,  a	 non-negative integer, namely a	shared
       memory identifier is returned.  Otherwise, a value of  -1  is  returned
       and is set to indicate the error.

ERRORS
       fails if	any of the following conditions	are encountered:

	      [EINVAL]	     size  is  less than the system-imposed minimum or
			     greater than the system-imposed maximum.

	      [EINVAL]	     A shared memory identifier	exists for key but  is
			     in	 64-bit	address	space and the process perform-
			     ing the request has been compiled as a 32-bit ex-
			     ecutable. In order	to avoid receiving this	error,
			     both and must be set in shmflg by the 64-bit pro-
			     cesses upon segment creation.

	      [EACCES]	     A shared memory identifier	exists for key but op-
			     eration permission	(see glossary(9)) as specified
			     by	 the  low-order	 9 bits	of shmflg would	not be
			     granted.

	      [EINVAL]	     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.

	      [ENOENT]	     A shared memory identifier	does not exist for key
			     and (shmflg & is ``false''.

	      [ENOSPC]	     A	shared	memory identifier is to	be created but
			     the system-imposed	limit on the maximum number of
			     allowed  shared  memory  identifiers  system wide
			     would be exceeded.

	      [ENOMEM]	     A shared memory identifier	and associated	shared
			     memory  segment are to be created,	but the	amount
			     of	available physical memory is not sufficient to
			     fill the request.

	      [ENOMEM]	     A	shared memory segment with or specified	was to
			     be	created; however, there	is not enough space in
			     the global	quadrant.

	      [EEXIST]	     A	shared	memory	identifier  exists for key but
			     ((shmflg &	&& (shmflg & is	``true''.

SEE ALSO
       ipcrm(1), ipcs(1), shmctl(2), shmop(2), ftok(3C).

STANDARDS CONFORMANCE
								     shmget(2)

NAME | SYNOPSIS | DESCRIPTION | EXAMPLES | RETURN VALUE | ERRORS | SEE ALSO | STANDARDS CONFORMANCE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=shmget&sektion=2&manpath=HP-UX+11.22>

home | help