slide 12 of 19


Using System V Shared Memory

  1. Start program as a single process
  2. Create a new shared segment of size b
    shmid = shmget(IPC_PRIVATE, b, (IPC_CREAT | 0666));
  3. Attach to it (map it)
    shmptr = shmat(shmid, 0, 0);
  4. Set segment to auto-destruct
    shmctl(shmid, IPC_RMID, 0);
  5. Use fork() to create processes
  6. Optionally call shmdt(shmptr); when done