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?
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.
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”.
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.
Use ipcmk. I never used it myself, so use
man ipcmk
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With