Shared memory is a System V IPC object that allows processes to share the same pages of memory. Any process can create shared memory, modify it and leave it for other processes to modify
later on. Shared memory exists until no processes are using it or system shutdown.
The data structure of the shared memory object is:
Create shared memory objects on the system:
Remove shared memory objects from the system:
The data structure of the shared memory object is:
struct shmid_ds
{
struct ipc_perm shm_perm;
size_t shm_segsz; /* size of segment */
pid_t shm_cpid; /* PID of creator */
pid_t shm_lpid; /* PID, last operation */
shmatt_t shm_nattch; /* no. of current attaches */
time_t shm_atime; /* time of last attach */
time_t shm_dtime; /* time of last detach */
time_t shm_ctime; /* time of last change */
};size_t shm_segsz; /* size of segment */
pid_t shm_cpid; /* PID of creator */
pid_t shm_lpid; /* PID, last operation */
shmatt_t shm_nattch; /* no. of current attaches */
time_t shm_atime; /* time of last attach */
time_t shm_dtime; /* time of last detach */
time_t shm_ctime; /* time of last change */
Both commands list all the shared memory objects in use on the system:
cat /proc/sysvipc/shm;
ipcs -m; ipcs -m -t; ipcs -m -p; ipcs -m -c; ipcs -m -l; ipcs -m -u;
Create shared memory objects on the system:
ipcmk -M <size in bytes> -p <permission bits>;
Remove shared memory objects from the system:
ipcrm -M <shared memory key>;
ipcrm -m <shared memory id>;
Do you have a suggestion about how to improve this blog? Let's talk about it. Contact me at David.Brenner.Jr@Gmail.com or 720-584-5229.
Comments
Post a Comment
Comments to this blog will be reviewed within 72 hours. No trolling please