Fork : number of processes created [closed]

2019-09-30 07:54发布

main(){
    int i; 
    for(i=0;i<4;i++) 
    fork(); 
    while(1);
}

Is the above graph, the output of the code?

标签: c fork
1条回答
放荡不羁爱自由
2楼-- · 2019-09-30 08:32

No, that's not quite correct though it's close. Think about the properties of all those processes down the left hand side. p0 creates four children, p1 creates three, and so on.

Since this is undoubtedly something you're supposed to nut out yourself, I won't make it any clearer, that should be more than enough to work it out. You may want to actually run the code and count how many processes are created. It's only slightly more than the fifteen you have.

查看更多
登录 后发表回答