父母或孩子:谁后fork()的第一个执行? [英] Who executes first after fork(): parent or the child?

查看:142
本文介绍了父母或孩子:谁后fork()的第一个执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,它可以是这些。但是,我总是看到孩子第一次执行我的UNIX终端上。另外,为什么不将家长和孩子并行执行。他们似乎被串行执行。这是因为它们共享同一个终端?

I know that it can be either of these. But I always see that the child executes first on my UNIX terminal. Also, why don't the parent and child execute in parallel. They seem to be executing serially. Is this because they share the same terminal?

推荐答案

在一般情况下,简直可以说他们执行的相对顺序。

In general, nothing can be said about the relative order of their execution.

现在,让我们考虑您的具体问题。如果:

Now, let's consider your specific problem. If:


  1. 这两个过程需要很长时间不平凡的量运行,

  2. 您是说,一个其他品牌的任何的进步,
  3. 运行前完成
  4. 有未使用的CPU周期和

  5. 发生这种情况每次运行应用程序时。

这很可能表明有一些(或许无意的)同步两个进程之间正在进行

Most likely this indicates that there is some (perhaps unintended) synchronization going on between the two processes.

这篇关于父母或孩子:谁后fork()的第一个执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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