Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux : create shared memory segment from shell command

I'd like to create a shared memory segment from a Unix startup script. The created segment would be accessed by several php scripts.

Is there a shell command to create a shared mem segment specifying key, mode, permissions and size?

like image 899
RoyHB Avatar asked Mar 18 '12 07:03

RoyHB


People also ask

What is shared memory segment in Linux?

Shared memory is a feature supported by UNIX System V, including Linux, SunOS and Solaris. One process must explicitly ask for an area, using a key, to be shared by other processes. This process will be called the server. All other processes, the clients, that know the shared area can access it.

What is Shmem in Linux?

SHMEM (from Cray Research's “shared memory” library) is a family of parallel programming libraries, providing one-sided, RDMA, parallel-processing interfaces for low-latency distributed-memory supercomputers. The SHMEM acronym was subsequently reverse engineered to mean "Symmetric Hierarchical MEMory”.

What function is used to write into a shared memory?

shmat() Function shmat() function is used to attach the created shared memory segment associated with the shared memory identifier specified by shmid to the calling process's address space.


2 Answers

Use ipcmk. I never used it myself, so use

man ipcmk
like image 171
laerne Avatar answered Oct 22 '22 10:10

laerne


You can use ipcrm to delete a shared memory segment, and ipcs to list shared memory segments ... but AFAIK you need to use a C program (or equivalent) to create a shared memory segment. There's no command I'm aware of to create one directly from the shell.

like image 24
paulsm4 Avatar answered Oct 22 '22 10:10

paulsm4