Creation and Destruction of Process In Unix

#include<stdio.h>
#include "shmlib.h"


main(){

int id, n;
//id is used for numbering each process, n is used for user to enter total number of processes

printf("This program creates user entered number minus one child processes,");
printf("\n Assign Task to each child process and once the the processing is complete, all child process are killed");
printf("\n Enter the nmber of processes : ");
// here user enter number of processes

scanf("%d",&n);
// creates process
id = create_process(n);

//conditions to check parallel execution by child if the id is greater than 0
id(id > 0){
printf("\n Parallel Execution");
printf("\n O/P from child %d My Id is : %d \n",id,id);
}
//condition to check for parent process
else if(id == 0){
printf("\n O/P from Parent Process : My id = %d",id);
}
join_process(n,id)
printf("\n Sequential Execution");
printf("Finished");
}

0 comments: