操作系統中的處理機調度調度
處理 (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
操作系統中的處理機調度調度