[Operating System] Process Management

some definitions

程序:静态指令的集合
进程:程序动态执行的过程,

Process classification

Three categories:

  • interactive process
  • batch process
  • daemon process

interactive process

Processes generally started by the shell

batch process

Execute sequentially through scripts, etc.

daemon process

For example: systemd
like apach service, etc.


  • user process
  • system process

According to the different process status, it is divided into

daemon process

1 - 所有的守护进程都可以 以 超级用户 的优先级运行
2 - 守护进程没有终端
3 - 守护进程的父进程都是init进程

orphan process

1 - 定义:父进程被终止,它的多个子进程还在运行,那么这些子进程称为 孤儿进程

2 - 孤儿进程会被 init 进程收养,并由init进程对它们完成状态收集工作

zombie process

1 - 定义:子进程结束,但没有释放内存,该进程称为 僵尸进程
2 - 当 僵尸进程 的父进程 结束后,该僵尸进程会被init进程所收养,最终会被回收
3 - 僵尸进程会导致资源的浪费,但是孤儿进程不会

Execution state of the process

1 - runnable
2 - sleeping
3 - zombie	#僵化状态,进程试图消亡
4 - stopped	#停止状态,进程被挂起

process management

Introduction to process-related commands - Author: "sudo

ps

a - 显示统一终端机器下的所有程序,包括其他用户的程序
u - 以用户为主的格式来显示程序状况
x - 显示所有程序,不以终端机来区分
l

top

Process priority and execution order

Pri(new)=Pri(old)+nice

1 - pri(old) - 优先级,pri越小,越快被执行
2 - 当nice为负值时,该程序将会被提前执行
3 - 只有root用户,可以将nice设置为负值

about nice

1 - 一般使用者可用nice值: 0-19
2 - root 可用nice值:-20 ~ 19

General format:

# nice [-n number] command
nice -n 3 firefox
# renice [number] PID 修改正在运行的进程的nice值
renice 3 1890

Guess you like

Origin blog.csdn.net/Sanayeah/article/details/126817306