shmp - /* shmp1.cpp */ #include "registration.h" #include...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* shmp1.cpp */ #include "registration.h" #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> #include <sys/shm.h> #include <sys/wait.h> #include <unistd.h> #include <stdlib.h> #include <iostream.h> #include <stdio.h> #include <memory.h> # CLASS myclass = { "1001", "120186", "Operating Systems", 15 }; C #define NCHILD 3 int shm_init( void * ); int sem_init( void ); void wait_and_wrap_up( int [], void *, int, int ); void rpterror( char *, char * ); r main(int argc, char *argv[]) { int child[NCHILD], i, shmid, semid; void *shm_ptr; char ascshmid[10], ascsemid[10], pname[14]; a strcpy (pname, argv[0]); shmid = shm_init(shm_ptr); semid = sem_init(); sprintf (ascshmid, "%d", shmid); sprintf (ascsemid, "%d", semid); s for (i = 0; i < NCHILD; i++) { child[i] = fork(); switch (child[i]) { case -1: rpterror ("fork failure", pname); exit(1); case 0: sprintf (pname, "shmc%d", i+1); execl("shmc", pname, ascshmid, ascsemid, (char *)0 ); perror ("execl failed"); exit (2); } } wait_and_wrap_up (child, shm_ptr, shmid, semid);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/11/2010 for the course CECS 326 taught by Professor Staff during the Spring '08 term at CSU Long Beach.

Page1 / 2

shmp - /* shmp1.cpp */ #include "registration.h" #include...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online