C Programming Tutorial

 
 
 
 
#include<stdio.h>

int process_fork(int x)
{
        int i;
        for(i=1;i<x;i++)
        {
                if(fork()==0)
                        return i;
        }
        return 0;
}

void process_join(int x,int id)
{
        int i;
        if(id==0)
        {
                for(i=1;i<x;i++)
                        wait(0);
        }
        else
                exit(0);
}

int* sh_mem(int x)
 {
   int shmid,*ptr;
   shmid=shmget(IPC_PRIVATE,x,0666|IPC_CREAT);

   if (shmid<0)
      printf(\"Error in creation of shared memory\\n\");
   ptr=(int *)shmat(shmid,0,0);
   return ptr;
 }

 
 
Didn't find what you were looking for? Find more on PROGRAM OF CREAT HEADER FILES FOR P_FORK,P_JOIN AND SHARED MEMORY