4.进程调度

image
image
image
image
image
image
image
image
image
image
image
image
image
image

实验:

ps -al:ps是将当前运行的进程的列出来, -a是显示和terminal关联的进程,-l是显示进程的详细信息。
ps就相当于任务管理

1

image
未fork()创建子进程
image
使用fork()创建子进程
image
image
image

2.

image

3.

image
image

4.验证父子进程值的空间是相互独立,互不干扰的
image
image

ps -el可以列出当前系统中所有在运行的进程
image
父进程先运行,父进程结束之后return 0返回,但是子进程还没有做完,就变成了孤儿进程(orphan)->系统把它托管给PID为1的系统进程。

wait(NULL)是一个系统调用,它的作用是,引发父进程主动让出CPU,进入到waiting状态,
等到子进程结束的时候才会从waiting状态返回到Ready状态。
但是再ubantu系统里,不写wait(NULL);也能够正常返回ppid。

sleep(3);
image

Review
image
image

posted @ 2023-02-09 17:47  nullptrException  阅读(10)  评论(0编辑  收藏  举报