叉:创建的进程数 [英] Fork : number of processes created

查看:180
本文介绍了叉:创建的进程数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

是上面图表中,code的输出?

Is the above graph, the output of the code?

推荐答案

没有,这是不完全正确,虽然已经很接近了。认为所有这些进程向下左手边的属性。 P0 创建了四个孩子, P1 创建三个,依此类推。

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.

由于这无疑是东西你应该螺母出自己,我不会让任何清晰的,这应该是绰绰有余去解决它。您可能需要实际的运行的code和算多少进程创建的。这只是比你有十五略多。

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.

这篇关于叉:创建的进程数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆