Fork : number of processes created [closed]

前提是你 提交于 2019-12-13 23:19:09

问题


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

Is the above graph, the output of the code?


回答1:


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.



来源:https://stackoverflow.com/questions/21273257/fork-number-of-processes-created

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!