您的位置:首页 > 房产 > 建筑 > 宁波公司地址_苏州诶茵诶公司网站_如何在百度上投放广告_自动点击竞价广告软件

宁波公司地址_苏州诶茵诶公司网站_如何在百度上投放广告_自动点击竞价广告软件

2024/10/5 20:27:24 来源:https://blog.csdn.net/2301_77479435/article/details/142367536  浏览:    关键词:宁波公司地址_苏州诶茵诶公司网站_如何在百度上投放广告_自动点击竞价广告软件
宁波公司地址_苏州诶茵诶公司网站_如何在百度上投放广告_自动点击竞价广告软件

冯诺依曼体系结构

操作系统(Operator System)

进程控制块(PCB)

struct task_struct{//该进程的所有属性//该进程对应的代码和属性地址struct task_struct* next;
};

struct task_struct 内核结构体——>创建内核结构体对象(task_struct)--->将对象和数据关联起来。

进程=内核数据结构(task_struct)+ 进程对应的磁盘代码

 while(true){cout<<"son:pid: "<<getpid()<<"    parent: "<<getppid()<<endl;sleep(1);}

son:pid: 6221    parent: 5912
son:pid: 6221    parent: 5912
son:pid: 6221    parent: 5912

son:pid: 6166parent: 5912
son:pid: 6166parent: 5912

多次运行父进程ppid不变。

命令行上启动的进程,一般父进程没有特殊情况的话,都是bash!!!

./"proc"
A proc, pid : 4018,ppid : 3997,id : 4019
A proc, pid : 4019,ppid : 4018,id : 0

fork

通过fork可以子进程。

 pid_t id=fork();printf("A proc, pid : %d,ppid : %d,id : %d\n",getpid(),getppid(),id);sleep(2);
pid_t id=fork();//printf("A proc, pid : %d,ppid : %d,id : %d\n",getpid(),getppid(),id);if(id==0){while(1){printf("Son proc, pid : %d,ppid : %d,id : %d\n",getpid(),getppid(),id);sleep(1);}}else if(id>0){while(1){printf("Par proc, pid : %d,ppid : %d,id : %d\n",getpid(),getppid(),id);sleep(1);}}else{}

Par proc, pid : 6856,ppid : 5912,id : 6857
Son proc, pid : 6857,ppid : 6856,id : 0
Par proc, pid : 6856,ppid : 5912,id : 6857
Son proc, pid : 6857,ppid : 6856,id : 0
Par proc, pid : 6856,ppid : 5912,id : 6857
Son proc, pid : 6857,ppid : 6856,id : 0

总结

fork()之后,会有父进程和子进程两个进程执行后续代码

fork后续的代码,被父子进程共享

通过返回值不同,让父子进程执行后续共享代码的一部分。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com