slide 12 of 19
Using System V Shared Memory
-
Start program as a single process
-
Create a new shared segment of size
b
shmid = shmget(IPC_PRIVATE, b, (IPC_CREAT | 0666));
-
Attach to it (map it)
shmptr = shmat(shmid, 0, 0);
-
Set segment to auto-destruct
shmctl(shmid, IPC_RMID, 0);
-
Use
fork()
to create processes
-
Optionally call
shmdt(shmptr);
when done