avatar
"fork" program question.# Unix - 噫吁兮,危乎高哉
w*a
1
Is my analysis for the following program correct? Many thanks.
Line 1) x = 10;
Line 2) if (fork()) x = x+5;
Line 3) if (x % 5 == 0) {
Line 4) if (fork()) x = x + 100;
}
At line 1, x = 10, this is for parent process 0.
At line 2, fork call will build a child process 1, in parent process 0, x =
15, but in child process x=5;
At line 3, both parent process 0 and child proces 1 will enter the if loop.
parent process 0 will build another child process 2, after finishing line 4,
the x in pa
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。