0
点赞
收藏
分享

微信扫一扫

操作系统 --进程控制

墨香子儿 2022-07-15 阅读 61


操作系统的

#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main() {
int p1,p2,i;
while((p1=fork())==-1);
if(p1==0) {
for(int i=1; i<=5000000; i++)
if(i%1000000==0)
printf("son %d\n",getpid());
} else {
while((p2=fork())==-1);
if(p2==0) {
for(int i=1; i<=5000000; i++)
if(i%1000000==0)
printf("daughter%d\n",getpid());
} else {
for(int i=1; i<=5000000; i++)
if(i%2000000==0)
printf("father%d\n",getpid());
}
}
return 0;
}


举报

相关推荐

0 条评论