ipcmk, ipcs, ipcrm are utilities on Linux to manuapilite System V interprocess communication (IPC) objects and associated data structures on Linux, though not fully compatible with POSIX ipc utility.

These 3 utilities are all part  of  the  util-linux-ng  package  and  is  available  from  ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/

Intr:

System  V IPC objects are of three types: shared memory, message queues, and semaphores.  Deletion of
a message queue or semaphore object is immediate (regardless of whether any process  still  holds  an IPC  identifier for the object).  A shared memory object is only removed after all currently attached processes have detached (shmdt(2)) the object from their virtual address space.

Create Share memory

utility ipcmk can create shared memory segment, a semaphore, or a message queue

$ ipcmk
Usage: ipcmk [options]
  -M <size>     create shared memory segment of size <size>
  -S <nsems>    create semaphore array with <nsems> elements
  -Q            create message queue
  -p <mode>     permission for the resource (default is 0644)

Example:

Create a Shared memory segment

$ ipcmk -M 1M
Shared memory id: 10715155
$ ipcs
------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
...  
0x130d3096 10715155   user1      644        1          0                       

Create a Semaphore

$ipcmk -S 3
Semaphore id: 163843

Create a Message Queue

$ipcmk -Q
Message queue id: 0

Check and list Share memory

ipcs provides information on ipc facilities for which you have read access.
Resource Specification:
    -m : shared_mem
    -q : messages
    -s : semaphores
    -a : all (default)

Example:

List Shared memory segments on Linux

(root list all user's, others list its own shared memory segments)

ipcs -m
------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x130d3096 10715155   user1      644        1          0         

List Message Queues

# ipcs -q
------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages    
0x03bb33a2 0         user1      644        0            0   

List Semaphore Arrays

ipcs -s
------ Semaphore Arrays --------
key        semid      owner      perms      nsems     
0x72f0100a 163843     user1      644        3      

Delete/remove a share memory

ipcrm
usage: ipcrm [ [-q msqid] [-m shmid] [-s semid]
          [-Q msgkey] [-M shmkey] [-S semkey] ... ]

Delete/remove a Shared Memory segment

$ ipcrm -m 10715155

Delete a message queue

$ipcrm -s 163843 

Delete a Semaphore

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages    
0x03bb33a2 0         user1      644        0            0   

$ipcrm -Q 0x03bb33a2

 

Want use shareable memory in perl ? see Perl Shareable Memory Examples