Course System Programming - Chapter 5
Course System Programming - Chapter 5
Memory Segment
key_t key;
int shmid;
key_t key;
int shmid;
char *data;
– The only argument, shmaddr, is the address you got from shmat().
– The function returns -1 on error, 0 on success.
10
Code Example
Or else,
• As always, you can destroy the shared memory segment from
the command line using the ipcrm Unix command.
ipcrm [–m shmid]
• Also, be sure that you don't leave any unused shared memory
segments sitting around wasting system resources.
• All the System V IPC objects you own can be viewed using
the ipcs command.
12
• Cons
– Needs concurrency control (leads to data
inconsistencies like ‘Lost update’)
– Lack of data protection from Operating System (OS)
12