J
Jani Yusef
I want to create a tree of processes. The depth of the tree is given
by the variable depth and the number of processes started by each node
is given by the variable numberOfProcesses.
Is the following code correct? I don't think it is, especially since I
don't want the bottom nodes(leaf nodes) to start any processes
themselves.
Any comments on the following code would be much appreciated!!
for(j=0;j<depth;j++){
for(i=0;i<numberOfProcesses;i=i+1){
if((pid=fork())< 0){
printf("Fork failed");
exit(1);
}
if(pid==0){
//then in child
}
if(pid){
//then in parent
}
}
}
by the variable depth and the number of processes started by each node
is given by the variable numberOfProcesses.
Is the following code correct? I don't think it is, especially since I
don't want the bottom nodes(leaf nodes) to start any processes
themselves.
Any comments on the following code would be much appreciated!!
for(j=0;j<depth;j++){
for(i=0;i<numberOfProcesses;i=i+1){
if((pid=fork())< 0){
printf("Fork failed");
exit(1);
}
if(pid==0){
//then in child
}
if(pid){
//then in parent
}
}
}