阅读背景:

C编程逻辑——尝试完成线程(fork),而不留下失效的过程

来源:互联网 

I'm in trouble trying to make this code to work. What I'm trying to do is to make my program to calculate some specific algorithm in parallel. Some times it works, some time is doesn't. This happens often when I run it with big numbers, but I can see in top (linux command) a lot of defunct processes and I think this happen because my forks are ending asyncronous and some childs are being left behind. But I thought in the beginning that my logic was at least making possible to finish all the calculations because I've set 2 control vars, flags and alldone, which are both shared memory space and are used to finish the while loop. I've been searching for some light and now I come here to ask for help since I can't find something that would help me. Can anyone help me with my logical problem in the following code in some way that my processes can be finished in the right sequence avoiding lefting defunct process behind? Thanks in advance!I'm in trouble trying to make this code to work




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: