forked from youngyangyang04/TechCPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
僵尸进程的产生通常发生在以下情况: | ||
|
||
1. 当一个子进程结束执行后,它会向父进程发送一个SIGCHLD信号,表示它已经执行完毕。 | ||
2. 根据操作系统的设计,父进程需要通过调用`wait()`或`waitpid()`函数来读取子进程的退出状态。这个操作被称为“收割”子进程。 | ||
3. 如果父进程没有调用这些函数,子进程的PCB就不会被清除,从而成为僵尸进程。 | ||
|
||
僵尸进程**本身不消耗除了PCB之外的资源,但如果大量的僵尸进程累积,它们将占用系统的进程表空间,可能会导致系统无法创建新的进程**。通常,僵尸进程是由于程序设计不当导致的,开发者应当确保进程能够被正确地清理。 | ||
|
||
当僵尸进程的父进程终止时,僵尸进程会被操作系统的init进程(或其他类似的系统进程)接管,并由它来完成收割工作,从而释放僵尸进程占用的PCB。在大多数现代操作系统中,这种现象是暂时的,因为系统设计确保了僵尸进程最终会被清理 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
### 外中断 | ||
|
||
- **来源**:外中断通常由处理器外部的事件引起,例如I/O设备(如键盘、鼠标、打印机等)、硬件计时器或其他计算机系统的信号。 | ||
- **异步性**:外中断是异步发生的,它们不是由程序的执行直接引起的,而是由外部硬件事件触发的。 | ||
- **硬件中断**:外中断也被称为硬件中断,因为它们通常涉及硬件设备。 | ||
- **目的**:外中断的主要目的是允许处理器对外设的操作做出响应,如响应用户的输入或处理完成信号。 | ||
|
||
### 内中断 | ||
|
||
- **来源**:内中断通常由程序执行中发生的事件引起,例如除零错误、无效指令、访问越界的内存地址等。 | ||
- **同步性**:内中断是同步发生的,它们是由程序的执行流程中的特定指令或条件触发的。 | ||
- **软件中断**:内中断也被称为软件中断,可以由特定的指令(如x86架构中的`INT`指令)直接调用。 | ||
- **目的**:内中断的主要目的是处理异常情况,如程序错误或特殊的程序控制流程。 | ||
|
||
### 共同点与区分 | ||
|
||
- **中断处理**:无论是外中断还是内中断,在处理器响应时,都会将当前的执行状态保存起来,转而执行一个特定的中断处理例程,处理完毕后再恢复原来的执行状态。 | ||
- **响应方式**:某些内中断(如软件中断)可以被程序员在代码中有意识地触发,而外中断通常是无法预知的,处理器必须随时准备响应。 |