操作系统中的处理机调度调度
处理 (Process)
In the operating system, there are numerous task and application program run simultaneously. A program is stored in the hard disk or any other form of secondary storage. When the program is executed it must be loaded in the system’s memory. A process can be viewed as a program in execution. In the system, each process is assigned a unique Id when it is created and it will be referenced by the unique Id until the process completes execution and it is terminated. A process is an entity which performs the basic unit of work or one work at a time. We can say that a process is an instance of a computer program that is being executed. A process contains the program code and the activity that is going to be performed. when the computer program is in secondary memory then it is a passive entity or when a process is in main memory then it is an active entity. In the system, several processes may be associated with the same program.
在操作系统中,有许多任务和应用程序同时运行。 程序存储在硬盘或任何其他形式的辅助存储中。 执行程序时,必须将其加载到系统内存中。 可以将进程视为正在执行的程序。 在系统中,每个进程在创建时都会分配一个唯一的ID,并且唯一ID会引用该ID,直到该进程完成执行并终止为止。 流程是一次执行基本工作单元或一项工作的实体。 我们可以说一个进程是一个正在执行的计算机程序的实例。 一个过程包含程序代码和将要执行的活动。 当计算机程序位于辅助内存中时,它是一个被动实体,或者当进程位于主内存中时,它是一个主动实体。 在系统中,几个进程可能与同一程序相关联。
A process held a number of attributes like hardware, memory, CPU, and progress.
一个进程拥有许多属性,例如硬件,内存,CPU和进度。
Craft.io分类 (Process classification)
A process can be broadly categorized into the following two types based on its execution:
根据流程的执行情况,大致可将其分为以下两种类型:
I/O-Bound process
I / O绑定过程
An I/O-bound process is a process whose execution time is determined mainly by the amount of time it spends completing I/O operations.
绑定到I / O的进程是其执行时间主要由其完成I / O操作所花费的时间确定的进程。
CPU-Bound process
CPU绑定进程
A CPU-bound process is a process whose execution time is determined by the speed of the CPU it runs on. A CPU-bound process can complete its execution faster if it is running on a faster processor.
受CPU限制的进程是其执行时间取决于其运行的CPU速度的进程。 如果受CPU约束的进程在更快的处理器上运行,则可以更快地完成其执行。
Note: There is a third category - Memory-bound process. However, since RAM serves as I/O for the processor, this can be considered as an instance of the I/O-bound process type.
注意:第三类-内存绑定进程。 但是,由于RAM用作处理器的I / O,因此可以将其视为I / O绑定进程类型的实例。
Further a process can be broadly categorized into the following two types based on execution mode.
另外,基于执行模式,可以将处理大致分为以下两种。
Kernel mode: In the kernel mode, a process has unrestricted access to the system hardware it can execute privileges instruction and can access both user and kernel address space.
内核模式:在内核模式下,进程可以不受限制地访问系统硬件,它可以执行特权指令,并且可以访问用户和内核地址空间。
Example: Most of the device drivers in the system execute as kernel mode processes.
示例:系统中的大多数设备驱动程序都以内核模式进程执行。
User mode: In the user mode it has no direct access to the underlying system hardware it can only access its own user address space of other processes and it cannot execute privileged instructions.
用户模式:在用户模式下,它不能直接访问基础系统硬件,只能访问其他进程自己的用户地址空间,并且不能执行特权指令。
Example: web- browser is executed as a user- mode process.
示例: Web浏览器作为用户模式进程执行。
Craft.io调度 (Process scheduling)
On a computer system, there are often numerous processes that need to be executed simultaneously. Furthermore, the requests for resources necessary for their execution are made asynchronously. Therefore, to handle competing requests for resources including the processor, the OS employs a process scheduler. The process scheduler assigns each process the necessary resources and its turn for execution on the CPU. The decision to schedule a process is made by a scheduling algorithm. The scheduler maintains three queues, to schedule the processes.
在计算机系统上,通常有许多进程需要同时执行。 此外,异步执行对执行其所需的资源的请求。 因此,为了处理对包括处理器在内的资源的竞争请求,OS使用了进程调度程序。 进程调度程序为每个进程分配必要的资源及其轮流,以便在CPU上执行。 调度流程的决定由调度算法做出。 调度程序维护三个队列,以调度进程。
Job queue: The job queue is the set of all processes on the system.
作业队列:作业队列是系统上所有进程的集合。
Ready queue: The ready queue has all the processes that are loaded in main memory. These processes are ready and waiting for their turn to execute as soon as the CPU becomes available.
就绪队列:就绪队列具有所有加载到主内存中的进程。 这些进程已准备就绪,等待轮到CPU可用时立即执行。
Device queue: The set of processes waiting for an I/O device to become available, such as a printer. This queue is also known as the Blocked Queue.
设备队列:等待I / O设备变得可用的一组进程,例如打印机。 此队列也称为阻塞队列。
流程执行 (Process Execution)
When a program is loaded into the memory (process memory) and it becomes a process and it can be divided into four sections, stack, heap, text and data.
当程序加载到内存(进程内存)中并成为一个进程时,可以分为四个部分:堆栈,堆,文本和数据。
Stack: The stack is used for local variables when the local variables are declared in the memory of some spaces on the stack is reserved for them.
堆栈:当局部变量在堆栈中某些空间的内存中被保留时,将堆栈用于局部变量。
Heap: The heap is used in the system for the dynamic memory allocation and it is managed by calls to new, delete, malloc, free like commands.
堆:堆在系统中用于动态内存分配,并且通过调用new,delete,malloc和free之类的命令进行管理。
Data section: The data section is made for of the global and the static variables when it is allocated and initialized prior to executing the main function.
数据部分:数据部分是在执行主功能之前进行分配和初始化时由全局变量和静态变量组成的。
Text section: The text section is made for the compiled program code when the program is launched it is read from non-volatile storage in the system.
文本部分:启动程序时,将从系统中的非易失性存储器中读取已编译的程序代码的文本部分。
Craft.io状态 (Process states)
When a process starts its execution it changes its states or goes through the various states. We can define a process states in parts by the current activity of that process. Each process may be in one or more in the states when it is executing.
当进程开始执行时,它会更改其状态或经历各种状态。 我们可以通过该过程的当前活动来部分定义一个过程状态。 每个进程在执行时可能处于一个或多个状态。
New
新
A process is in the new states when it is newly created in the system.
在系统中新创建进程后,该进程将处于新状态。
Ready
准备
When the process is created it move to the ready state and in this state, the process is ready for their execution.
创建流程后,它将进入就绪状态,在此状态下,流程已准备好执行。
Run
跑
A process in the running state when it is currently running process in the CPU. At a time only one process can be under execution in a single processor.
当前正在CPU中运行的进程时,处于运行状态的进程。 一次只能在一个处理器中执行一个进程。
Wait or block
等待或封锁
When the process is executed for I/O it moves to the wait or block state.
当为I / O执行该过程时,它将进入等待或阻止状态。
Terminated or completed
终止或完成
When the process completed its execution it enters into the terminated state. In this states, all the changes made by the process permanently save on the memory.
进程完成执行后,将进入终止状态。 在这种状态下,该过程所做的所有更改将永久保存在内存中。
Suspended ready
暂停准备
When the ready queue is full some process move to the suspend ready state so that there is no load on the ready queue.
当就绪队列已满时,某些进程将移至暂挂就绪状态,以使就绪队列上没有负载。
Suspended block
悬浮块
When the waiting queue is full some processes move to the suspend ready state so that there is no load on the block state.
当等待队列已满时,某些进程将移至暂挂就绪状态,以便在块状态上没有负载。
A process is not itself a process it is actually a passive entity so its content is stored in the hard disk whereas a running process is a passive entity so the program counter counts the next instruction to be executed. In the system, two processes may be linked with the same program and these process cannot be considered as two separate processes. For any instances, many users may be running at the main program.
一个进程本身并不是一个进程,它实际上是一个被动实体,因此它的内容存储在硬盘中,而正在运行的进程是一个被动实体,因此程序计数器会计算下一条要执行的指令。 在系统中,两个进程可能与同一程序链接,并且这些进程不能视为两个单独的进程。 对于任何情况,许多用户可能正在主程序上运行。
翻译自: https://www.includehelp.com/operating-systems/process-classification-and-scheduling.aspx
操作系统中的处理机调度调度