how about this? int p = 1; int q = 1; pid_t c = fork(); if(c == 0) { while(p > 0) ; q-- } else if (c > 0) { while(q > 0) ; p--; } else { perror("fork error"); } else { perror("fork error"); }
【在 P*******b 的大作中提到】 : 咋解释?
P*b
9 楼
还是不太明白啊
【在 d**e 的大作中提到】 : how about this? : int p = 1; : int q = 1; : pid_t c = fork(); : if(c == 0) : { : while(p > 0) : ; : q-- : }
I*A
10 楼
os的那点东西全忘光了 这个parent and child process之间 vs 这个child process and child process之间 的deadlock, 有本质区别麽?
【在 P*******b 的大作中提到】 : in what case can parent and child process gets into deadlock? if not why?
d*e
11 楼
modified a little bit. when c=0, it's child process when c>0, it's parent process so they are mutual waiting, one for q, one for p. but i don't know if the busy waiting is a good example or not, or i am on the right track. correct me if made a mistake.
【在 P*******b 的大作中提到】 : 还是不太明白啊
d*e
12 楼
我觉得都是等解锁。 呼唤大牛来回答……
【在 I**A 的大作中提到】 : os的那点东西全忘光了 : 这个parent and child process之间 : vs : 这个child process and child process之间 : 的deadlock, 有本质区别麽?