Scheduling 调度

Linux 进程、线程与调度.pdf

进程

我们编写的代码只是一个存储在硬盘的静态文件,通过编译后就会生成二进制可执行文件, 当我们运行这个可执行文件后,它会被装载到内存中,接着 CPU 会执行程序中的每一条指 令,那么这个运行中的程序,就被称为「进程」(Process)

当进程要从硬盘读取数据时,CPU 不需要阻塞等待数据的返回,而是去执行另外的进 程。当硬盘数据返回时,CPU 会收到个中断,于是 CPU 再继续运行这个进程。

状态

进程活动期间至少具备三种基本状态,即运行状态、就绪状态、阻塞状态;另外两种基本状态:创建和结束。

Untitled

Untitled

Critical Regions 临界区

The problem of avoiding race conditions can also be formulated in an abstract way. Part of the time, a process is busy doing internal computations and other things that do not lead to race conditions. However, sometimes a process has to access shared memory or files, or do other critical things that can lead to races. That part of the program where the shared memory is accessed is called the critical region or critical section.

InterProcess Communication IPC

Three types of IPCs: