#include "forkjoin.h"
#include "shared.h"
main()
{
int a[10],n;
int *flag,fect=1,nproc;
int i,pid,shmid;
printf("Enter the value of the no. n : ");
scanf("%d",&n);
printf("Enter the no. of process : ");
scanf("%d",&nproc);
flag=(int *) create_memory(sizeof(int)*nproc,&shmid);
for(i=0;i<nproc;i++)
flag[i]=0;
pid=create_process(nproc);
for(i=pid+2;i<n;i+=nproc)
{
if(n%i==0)
flag[pid]=1;
}
join_process(nproc,pid);
for(i=0;i<nproc;i++)
{
if(flag[i]==1)
{
printf("Given no. is not prime\n");
exit(1);
}
}
printf("Given no. is prime\n",fect);
clear_memory(&shmid);
}