chap2123 處理器中斷技術進程及其實現(xiàn)2013_第1頁
chap2123 處理器中斷技術進程及其實現(xiàn)2013_第2頁
chap2123 處理器中斷技術進程及其實現(xiàn)2013_第3頁
chap2123 處理器中斷技術進程及其實現(xiàn)2013_第4頁
chap2123 處理器中斷技術進程及其實現(xiàn)2013_第5頁
已閱讀5頁,還剩154頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、操作系統(tǒng)第二章 處理器管理,南京大學軟件學院 2013,第二章 處理器管理,2.1 中央處理器 2.2 中斷技術 2.3 進程及其實現(xiàn) 2.4 線程及其實現(xiàn) 2.5 Linux進程和線程 2.6 Windows 2003進程和線程 2.7 處理器調度 2.8 處理器調度算法 2.9 Linux調度算法 2.10 Windows 2003調度算法,2.1中央處理器,計算機組織結構 處理器寄存器 指令執(zhí)行 多處理器系統(tǒng)與多核處理器系統(tǒng),2.1中央處理器1. 計算機組織結構,Processor Main Memory referred to as real memory or primary mem

2、ory Volatile(揮發(fā)的 持久的 persistent) I/O modules Secondary memory devices Input/Output devices, terminals Communications equipment System bus communication among processors, memory, and I/O modules,Top-Level Components,User-visible Registers Enable programmer to minimize main-memory references by optimi

3、zing register use Control and Status Registers Used by processor to control operating of the processor Used by operating-system routines to control the execution of programs,2.1中央處理器2. 處理器寄存器,User-Visible Registers,May be referenced by machine language Available to all programs - application program

4、s and system programs Types of registers Data Address,User-Visible Registers,Address Registers Index: involves adding an index to a base value to get an address Segment pointer: when memory is divided into segments, memory is referenced by a segment and an offset Stack pointer: points to top of stac

5、k,Control and Status Registers,Program Counter (PC) Contains the address of an instruction to be fetched Instruction Register (IR) Contains the instruction most recently fetched Program Status Word (PSW): record all status of an executing program. (the term used by OS) Program counter condition code

6、s Interrupt enable/disable Supervisor/user mode,Control and Status Registers,Condition Codes or Flags Bits set by the processor hardware as a result of operations Can be accessed by a program but not altered Examples positive result negative result zero Overflow,特權指令和處理器狀態(tài),從資源管理和控制程序執(zhí)行的角度出發(fā),必須設置特權指令

7、,提供給操作系統(tǒng)的核心程序使用 處理器狀態(tài) 管理狀態(tài)(特權狀態(tài)、系統(tǒng)模式、特態(tài)或管態(tài)): 處理器可以執(zhí)行全部指令,使用所有資源,并具有改變處理器狀態(tài)的能力 用戶狀態(tài)(目標狀態(tài)、用戶模式、常態(tài)或目態(tài)): 處理器只能執(zhí)行非特權指令 核心狀態(tài)、管理狀態(tài)和用戶狀態(tài),Pentium的處理器狀態(tài),0級為操作系統(tǒng)內核級:處理I/O、存儲管理、和其他關鍵操作 1級為系統(tǒng)調用處理程序級:用戶程序可以通過調用這里的過程執(zhí)行系統(tǒng)調用,但是只有一些特定的和受保護的過程可以被調用 2級為共享庫過程級:它可以被很多正在運行的程序共享,用戶程序可以調用這些過程,讀取它們的數(shù)據(jù),但是不能修改它們 3級為用戶程序級,IBM的程

8、序狀態(tài)字寄存器,CMWP位依次為基本/擴充控制方式位、開/關中斷位、運行/等待位、目態(tài)/特態(tài)位,2.1中央處理器3.指令執(zhí)行: 指令與指令寄存器,Types of instructions Processor-memory: transfer data between processor and memory Processor-I/O: data transferred to or from a peripheral device Data processing: arithmetic or logic operation on data Control: alter sequence of

9、 execution Fetched instruction is placed in the instruction register,Instruction Cycle,Instruction Fetch and Execute,The processor fetches the instruction from memory Program counter (PC) holds address of the instruction to be fetched next Program counter is incremented after each fetch,Example of P

10、rogram Execution,I/O Function,I/O exchanges occur directly with memory Processor grants I/O module authority to read from or write to memory Relieves the processor responsibility for the exchange Example: Direct Memory Access (DMA),多處理器系統(tǒng)分類: 共享存儲(緊密耦合)多處理機系統(tǒng) 分布存儲(松散耦合)多處理機系統(tǒng)。 多處理器指在一個體系結構上放置多個CPU芯片,

11、而多核則指在同一塊CPU芯片上放置多個核(core),即執(zhí)行單元。,2.1中央處理器4.多處理器系統(tǒng)與多核處理器系統(tǒng),多處理器系統(tǒng)與多核處理器系統(tǒng),x86體系結構下,處理器4個演變階段。 (1) 多處理器結構、 (2) 超線程結構、 (3)多核結構、 (4)多核超線程結構。,(1)多處理器結構,多處理器系統(tǒng)與多核處理器系統(tǒng),(2)超線程結構,多處理器系統(tǒng)與多核處理器系統(tǒng),雙核,多處理器系統(tǒng)與多核處理器系統(tǒng),(3)多核結構,Intel 酷睿 i7 四核CPU,四核,多處理器系統(tǒng)與多核處理器系統(tǒng),(3)多核結構,(4)多核超線程結構,多處理器系統(tǒng)與多核處理器系統(tǒng),操作系統(tǒng)與多核處理器,處理器通信支

12、持 進程/線程數(shù)據(jù)共享支持 存儲器層次及管理 程序并行執(zhí)行模型支持 同步支持 調度及優(yōu)化 能耗管理,多處理器系統(tǒng)與多核處理器系統(tǒng),2.2中斷技術,中斷概念與中斷事件處理 中斷優(yōu)先級和多重中斷 Linux中斷處理 Windows 2003中斷處理,中斷的定義,中斷是指程序執(zhí)行過程中,遇到急需處理的事件時,暫時中止CPU上現(xiàn)行程序的運行,轉去執(zhí)行相應的事件處理程序,待處理完成后再返回原程序被中斷處或調度其他程序執(zhí)行的過程。,2.2中斷技術,1.中斷概念與中斷事件處理,An interruption of the normal sequence of execution Improves proce

13、ssing efficiency Allows the processor to execute other instructions while an I/O operation is in progress A suspension of a process caused by an event external to that process and performed in such a way that the process can be resumed,2.2中斷技術,Classes of Interrupts,Program arithmetic overflow divisi

14、on by zero execute illegal instruction reference outside users memory space Timer I/O Hardware failure,Interrupt Handler,A program that determines nature of the interrupt and performs whatever actions are needed Control is transferred to this program Generally part of the operating system,Interrupt

15、Cycle,Interrupt Cycle,Processor checks for interrupts If no interrupts fetch the next instruction for the current program If an interrupt is pending, suspend execution of the current program, and execute the interrupt handler,中斷與中斷源,強迫性中斷事件 硬件故障中斷事件(硬件故障引起) 電源故障, 主存儲器故障, 程序性中斷事件(執(zhí)行機器指令引起) 除數(shù)為零, 操作數(shù)溢

16、出, 非法指令, 目態(tài)下使用特權指令, 地址越界, 外部中斷事件(外部事件引起) 時鐘中斷, 重啟動中斷, I/O中斷事件(I/O控制系統(tǒng)發(fā)現(xiàn)外設完成I/O或I/O出錯引起) 打印完成, 打印缺紙, ,中斷與中斷源,自愿性中斷事件 (進程執(zhí)行訪管指令請求OS服務引起) 請求分配外設, 請求I/O, 關于中斷的分類 中斷、異常與系統(tǒng)服務(中斷俘獲、陷阱、系統(tǒng)陷阱) 內中斷、外中斷、軟中斷、自由中斷,兩類中斷事件的中斷處理過程,兩類中斷事件與中斷處理過程,中斷裝置,中斷寄存器: 記錄強迫性中斷事件的寄存器,每一種中斷可設置一個中斷寄存器 中斷字: 中斷寄存器的內容, 記錄了所發(fā)生中斷的類型和原因(

17、如I/O中斷的中斷字為”通道號,設備號”) 中斷裝置是一種硬件, 當中斷事件發(fā)生后, 它能改變處理器內操作的順序,中斷裝置與中斷響應,發(fā)現(xiàn)中斷源,提出中斷請求 發(fā)現(xiàn)內容非零的中斷寄存器 決定這些中斷是否應該屏蔽 當有多個要響應的中斷源時,根據(jù)規(guī)定的優(yōu)先級選取一個 把中斷字送到當前PSW的中斷碼字段 中斷當前程序的執(zhí)行 保存當前程序的PSW到內存約定單元 啟動操作系統(tǒng)的中斷處理程序 從內存約定單元取出中斷處理程序的PSW,中斷裝置與中斷響應,中斷的處理,中斷處理程序 處理中斷事件的控制程序, 主要任務是處理中斷事件和恢復正常操作 中斷處理過程 保護未被硬件保護的一些必需的處理狀態(tài) 通過分析被中斷

18、進程的PSW中斷碼字段,識別中斷源 分別處理發(fā)生的中斷事件 恢復正常操作,處理器中斷事件的處理,電源故障的處理: 處理器現(xiàn)場信息送主存 停止外圍設備工作 停止處理器工作 故障排除后, 從約定點重新啟動操作系統(tǒng) 必要時操作員干預 主存儲器故障的處理 中止有關程序的運行, 向操作員報告,程序性中斷事件的處理,對于無法克服的程序性中斷事件(如非法指令, 目態(tài)下使用特權指令, 地址越界, ): 向操作員報告請求干預 對于除數(shù)為零, 操作數(shù)溢出等程序性中斷事件: 可以由用戶程序自行處理, 或由操作系統(tǒng)進行標準處理,外部中斷事件的處理,時鐘中斷事件: 每隔一個時間間隔發(fā)生一次, 操作系統(tǒng)自動更改系統(tǒng)時鐘和

19、間隔時鐘的計時;且當間隔時鐘寄存器的值為臨界值時, 操作系統(tǒng)進行專門處理 控制臺中斷事件(重啟動中斷, 關機中斷, ): 操作員利用控制臺發(fā)出命令, 請求服務, 操作系統(tǒng)響應并服務,自愿性中斷事件的處理,用戶程序執(zhí)行系統(tǒng)調用(訪管指令,廣義指令); 操作系統(tǒng)把系統(tǒng)調用參數(shù)作為中斷字, 分析檢查后進行相應處理,中斷控制流程,2.2中斷技術,2.中斷優(yōu)先級與多重中斷,中斷優(yōu)先級與中斷屏蔽,中斷優(yōu)先級:當計算機同時檢測到多個中斷時, 中斷裝置響應中斷的順序。常見的處理次序可能是處理器中斷事件、自愿性中斷事件、程序性中斷事件、時鐘中斷等外部中斷事件、輸入輸出中斷事件、重啟動和關機中斷事件 中斷屏蔽:當

20、計算機檢測到中斷時, 中斷裝置通過中斷屏蔽位決定是否響應已發(fā)生的中斷,中斷優(yōu)先級與中斷屏蔽,決定中斷處理次序的因素 中斷屏蔽可以使中斷裝置不響應某些中斷 中斷優(yōu)先級決定了中斷裝置響應中斷的次序 中斷可以嵌套處理, 但嵌套的層數(shù)應有限制 中斷的嵌套處理改變了中斷處理的次序,(1) Linux內核處理流程,2.2中斷技術,3.Linux中斷處理,快中斷與慢中斷, Linux中,區(qū)分快中斷和慢中斷兩類中斷事件。 處理慢中斷前需保存所有寄存器的內容,而快中斷處理僅要保存被常規(guī)C函數(shù)修改的寄存器;慢中斷處理時,不屏蔽其他中斷信號,而快中斷處理時會屏蔽所有其他中斷; 慢中斷處理完畢后,通常不立即返回被中斷

21、的進程,而是進入調度程序重新調度,調度結果未必是被中斷的進程運行(是搶先式調度)。而快中斷處理完畢后,通?;謴同F(xiàn)場返回被中斷的進程繼續(xù)執(zhí)行(是非搶先式調度)。,(2) 下半部分處理概述,中斷處理程序的特點 什么是下半部分處理? Top half Bottom half,中斷處理程序特點,以異步方式運行,可能會打斷關鍵代碼的執(zhí)行,甚至打斷其他中斷處理程序的執(zhí)行; 在屏蔽中斷狀態(tài)下運行,最壞的情況會禁止所有中斷; 要對硬件進行操作,有很高的時限要求;它在中斷上下文中運行,故不能被阻塞 。,Linux各種下半部分機制,bottom half、 task queue、 tasklet、 work qu

22、eue、 Softirq。,Windows2003陷阱調度,2.2中斷技術,3. Windows 2003中斷處理,Windows2003中斷請求級別,Windows 2003中斷屏蔽,系統(tǒng)服務調度(1),A0,SUB0,SUB1,SUBi,SUBn,A1,Ai,An,A0,A1,Ai,An,系統(tǒng)調用的處理過程,System Call,用戶程序,系統(tǒng)調用處理子程序,取系統(tǒng)功能號 找入口地址表 相應入口地址,結束處理 恢復現(xiàn)場,保護CPU現(xiàn)場,自陷指令,系統(tǒng)調用陷入機構,入口地址表,系統(tǒng)服務調度(2),61,第二章 處理器管理,2.1 中央處理器 2.2 中斷技術 2.3 進程及其實現(xiàn) 2.4

23、線程及其實現(xiàn) 2.5 Linux進程和線程 2.6 Windows 2003進程和線程 2.7 處理器調度 2.8 處理器調度算法 2.9 Linux調度算法 2.10 Windows 2003調度算法,本主題教學目標,掌握進程的概念,可再入過程 掌握進程的狀態(tài)、進程的掛起,以及隊列實現(xiàn)模型 掌握操作系統(tǒng)的控制結構 掌握進程描述與控制的數(shù)據(jù)結構 掌握處理機模式的概念 掌握進程創(chuàng)建、模式切換、進程切換、進程隊列、進程原語等進程實現(xiàn)的原理 了解操作系統(tǒng)的執(zhí)行模型 了解SVR4的進程管理,2.3 進程及其實現(xiàn),進程的概念 進程的狀態(tài)和轉換 進程的描述和組成 進程控制和管理,Major Require

24、ments of an OS,Interleave the execution of several processes to maximize processor utilization while providing reasonable response time Allocate resources to processes Support interprocess communication(IPC) and user creation of processes,1. 進程的概念,Process,Also called a task Execution of an individua

25、l program Can be traced list the sequence of instructions that execute,Process Definition,進程是一個具有一定獨立功能的程序關于某個數(shù)據(jù)集合的一次運行活動 A process is a program in execution, including: Process id and Data structure for process management and execution Code: program in memory Data: data in memory and its values Reg

26、ister values Program status word,Process Definition,Processi: (Pi, Ci, Di, Ri, Pswi) Program(data) Program(data) in memory (P1, C1, D1, R1, Psw1) and (P2, C2, D2, R2, Psw2) C1 and C2(different program) , but D1 and D2(different data) C1 and C2(different program) , but D1 and D2(same data) C1 and C2(

27、same program), but D1 and D2(different data) C1 and C2(same program), but D1 and D2(same data) (P1, C1, D1, R1, Psw1) and (P2, C2, D1, R2, Psw2) Concurrent programming(in fact, only share some data) (P1, C1, D1, R1, Psw1) and (P2, C1, D2, R2, Psw2) Share code(Reentrant program, Reentrant Procedure),

28、Process States Two-State Process Model Three-State Process Model Five-State Process Model Process Suspend,2. 進程的狀態(tài)和轉換,Two-State Process Model,Process may be in one of two states Running Not-running,2. 進程的狀態(tài)和轉換,Not-Running Process in a Queue,Process Creation,Submission of a batch job User logs on Cre

29、ated to provide a service such as printing Process creates another process,Process Termination,Batch job issues Halt instruction User logs off Quit an application Error and fault conditions,Reasons for Process Termination,Normal completion Time limit exceeded Memory unavailable Bounds violation Prot

30、ection error example write to read-only file Arithmetic error Time overrun process waited longer than a specified maximum for an event,Reasons for Process Termination,I/O failure Invalid instruction happens when try to execute data Privileged instruction Data misuse Operating system intervention suc

31、h as when deadlock occurs Parent terminates so child processes terminate Parent request,Process States Two-State Process Model Three-State Process Model Five-State Process Model Process Suspend,2. 進程的狀態(tài)和轉換,Three-State Process Model,Not-running(Ready ) ready to execute Blocked(Waiting ) waiting for I

32、/O Dispatcher cannot select the blocked process,2. 進程的狀態(tài)和轉換,Process State: Three States,Running, Ready, and Blocked(Wait),Process State: Three States,運行態(tài)等待態(tài):等待使用資源;等待外設傳輸;等待人工干預/信號 等待態(tài)就緒態(tài):資源得到滿足;外設傳輸結束;人工干預/信號完成 運行態(tài)就緒態(tài):運行時間到;出現(xiàn)有更高優(yōu)先權進程 就緒態(tài)運行態(tài):CPU空閑時選擇一個就緒進程,Process States Process Two-State Process M

33、odel Three-State Process Model Five-State Process Model Process Suspend,2. 進程的狀態(tài)和轉換,Five-State Process Model,Running Ready Blocked New Exit,2. 進程的狀態(tài)和轉換,Five-State Process Model,Process State: Five States,NULL新建態(tài):執(zhí)行一個程序/創(chuàng)建一個子進程 新建態(tài)就緒態(tài):當OS完成了進程創(chuàng)建的必要操作,且當前系統(tǒng)的性能和虛擬內存的容量均允許 運行態(tài)終止態(tài):當一個進程到達了自然結束點,或出現(xiàn)了無法克服的

34、錯誤,或被操作系統(tǒng)所終結,或被其他有終止權的進程所終結 終止態(tài)NULL:完成善后操作 就緒態(tài)終止態(tài):未在狀態(tài)轉換圖中顯示,但某些操作系統(tǒng)允許父進程終結子進程 等待態(tài)終止態(tài):未在狀態(tài)轉換圖中顯示,但某些操作系統(tǒng)允許父進程終結子進程,Using Two Queues,89,事件1 發(fā)生,事件2 發(fā)生,事件n 發(fā)生,允許進入,分派,釋放,分派,分派,Yet another queuing model:每個優(yōu)先級對應一個就緒隊列,90,有掛起態(tài)的排隊模型, 每個事件一個阻塞隊列,91,Representation of Process Scheduling,Process States Process

35、 Two-State Process Model Three-State Process Model Five-State Process Model Process Suspend,2. 進程的狀態(tài)和轉換,Suspended Processes,Processor is faster than I/O so all processes could be waiting for I/O Swap these processes to disk to free up more memory Blocked state becomes suspend state when swapped to d

36、isk Two new states Blocked, suspend Ready, suspend,2. 進程的狀態(tài)和轉換,Process State: Suspended,由于進程的不斷創(chuàng)建,系統(tǒng)的資源已經(jīng)不能滿足進程運行的要求,這個時候就必須把某些進程掛起(suspend),對換到磁盤鏡像區(qū)中,暫時不參與進程調度,起到平滑系統(tǒng)操作負荷的目的,One Suspend State,Two Suspend States,97,改進:每個優(yōu)先級一就緒個隊列,Process State: Suspended,一個掛起進程等同于不在主存的進程,它將不參與進程調度直到它們被對換進主存。它具有如下特征:

37、 該進程不能立即被執(zhí)行 掛起進程可能會等待一個事件,但所等待的事件是獨立于掛起條件的,事件結束并不能導致進程具備執(zhí)行條件 進程進入掛起狀態(tài)是由于操作系統(tǒng)、父進程或進程本身阻止它的運行 結束進程掛起狀態(tài)的命令只能通過操作系統(tǒng)或父進程發(fā)出,Process State: Suspended,等待態(tài)掛起等待態(tài):如果當前不存在就緒進程,那么至少有一個等待態(tài)進程將被對換出去成為掛起等待態(tài);操作系統(tǒng)根據(jù)當前資源狀況和性能要求,也可以決定把等待態(tài)進程將被對換出去成為掛起等待態(tài) 掛起等待態(tài)掛起就緒態(tài):引起進程等待的事件發(fā)生之后,相應的掛起等待態(tài)進程將轉換為掛起就緒態(tài) 就緒態(tài)掛起就緒態(tài):操作系統(tǒng)根據(jù)當前資源狀況和

38、性能要求,也可以決定把就緒態(tài)進程將被對換出去成為掛起就緒態(tài),Process State: Suspended,運行態(tài)掛起就緒態(tài):當一個具有較高優(yōu)先級的掛起等待態(tài)進程的等待事件結束后,它需要搶占了CPU,而此時主存空間有不夠,從而可能導致正在運行的進程轉化為掛起就緒態(tài)。另外處于運行態(tài)的進程也可以自己掛起自己 新建態(tài)掛起就緒態(tài):考慮到系統(tǒng)當前資源狀況和性能要求,可以決定新建的進程將被對換出去成為掛起就緒態(tài),Process State: Suspended,掛起就緒態(tài)就緒態(tài):當內存中沒有就緒態(tài)進程,或者掛起就緒態(tài)進程具有比就緒態(tài)進程更高的優(yōu)先級,系統(tǒng)將把掛起就緒態(tài)進程轉換成就緒態(tài) 掛起等待態(tài)等待態(tài):

39、當一個進程等待一個事件時,原則上時不需要把它調入內存的。但是在下面一種情況下,這一狀態(tài)變化時可能的。當一個進程退出后,主存已經(jīng)有了一大塊自由空間,而某個掛起等待態(tài)進程具有較高的優(yōu)先級并且操作系統(tǒng)已經(jīng)得知導致它阻塞的事件即將結束,此時便發(fā)生了這一狀態(tài)變化,Reasons for Process Suspension,Process Description and Control,Process States Process Description Processes and Resources OS Control Structures Process Control Structures Pr

40、ocess Control Examples: Process,3. 進程的描述和組成,Process Description,Process Description and Control,Process States Process Description Processes and Resources OS Control Structures Process Control Structures Process Control Examples: Process,3. 進程的描述和組成,Operating System Control Structures,Information ab

41、out the current status of each process and resource Tables are constructed for each entity the operating system manages,Memory Tables,Allocation of main memory to processes Allocation of secondary memory to processes Protection attributes for access to shared memory regions Information needed to man

42、age virtual memory,I/O Tables,I/O device is available or assigned Status of I/O operation Location in main memory being used as the source or destination of the I/O transfer,File Tables,Existence of files Location on secondary memory Current Status Attributes Sometimes this information is maintained

43、 by a file-management system,Process Table,Where process is located Attributes necessary for its management Process ID Process state Location in memory,OS Control Structure,Process Description and Control,Process States Process Description Processes and Resources OS Control Structures Process Contro

44、l Structures Process Location Process Attributes Process Control Examples: Process,3. 進程的描述和組成,Process Location,Process includes set of programs and data Programs: the program to be executed User Data: the modifiable part of the user space, include program data, user stack, and program that may be m

45、odified System Stack: used to store parameters and calling addresses for system call Process Control Block (PCB): Collection of attributes Process image Collection of program, data, stack, and attributes (PCB),114,進程映像 進程控制塊:存儲進程標志信息、現(xiàn)場信息和控制信息。 進程程序塊:被執(zhí)行的程序,規(guī)定進程一次運行應完成的功能。通常它是純代碼,作為一種系統(tǒng)資源可被多個進程共享。 進

46、程核心棧:每個進程捆綁一個,進程在核心態(tài)下工作時使用,用來保存中斷/異?,F(xiàn)場,及執(zhí)行函數(shù)調用的參數(shù)和返回地址,系統(tǒng)調用的參數(shù)和返回地址等。 進程數(shù)據(jù)塊:即進程私有地址空間,存放各種私有數(shù)據(jù),用戶棧也在數(shù)據(jù)塊中開辟,用于函數(shù)調用時存放棧幀、局部變量等參數(shù),包括程序數(shù)據(jù)、用戶棧和可修改的程序。,3. 進程的描述和組成,115,程序塊,數(shù)據(jù)塊,PCB,進程映像,核心棧,Process Description and Control,Process States Process Description Processes and Resources OS Control Structures Proc

47、ess Control Structures Process Location Process Attributes Process Control Examples: Process,3. 進程的描述和組成,Process Control Block,Process identification Identifiers Numeric identifiers that may be stored with the process control block include Identifier of this process Identifier of the process that cr

48、eated this process (parent process) User identifier,Process Control Block,Processor State Information User-Visible Registers A user-visible register is one that may be referenced by means of the machine language that the processor executes. Typically, there are from 8 to 32 of these registers, altho

49、ugh some RISC implementations have over 100.,Process Control Block,Processor State Information Control and Status Registers These are a variety of processor registers that are employed to control the operation of the processor. These include Program counter: Contains the address of the next instruct

50、ion to be fetched Condition codes: Result of the most recent arithmetic or logical operation (e.g., sign, zero, carry, equal, overflow) Status information: Includes interrupt enabled/disabled flags, execution mode,Process Control Block,Processor State Information Stack Pointers Each process has one

51、or more last-in-first-out (LIFO) system stacks associated with it. A stack is used to store parameters and calling addresses for procedure and system calls. The stack pointer points to the top of the stack.,Process Control Block,Process Control Information Scheduling and State Information: This is i

52、nformation that is needed by the operating system to perform its scheduling function. Typical items of information: Process state Priority Scheduling-related information: This will depend on the scheduling algorithm used Event: Identity of event the process is awaiting before it can be resumed,Proce

53、ss Control Block,Process Control Information Data Structuring A process may be linked to other process in a queue, ring, or some other structure. For example, all processes in a waiting state for a particular priority level may be linked in a queue. A process may exhibit a parent-child (creator-crea

54、ted) relationship with another process. The process control block may contain pointers to other processes to support these structures.,Process Control Block,Process Control Information InterProcess Communication Various flags, signals, and messages may be associated with communication between two in

55、dependent processes. Some or all of this information may be maintained in the process control block.,Process Control Block,Process Control Information Process Privileges Processes are granted privileges in terms of the memory that may be accessed and the types of instructions that may be executed. I

56、n addition, privileges may apply to the use of system utilities and services.,Process Control Block,Process Control Information Memory Management This section may include pointers to segment and/or page tables that describe the virtual memory assigned to this process. Resource Ownership and Utilizat

57、ion Resources controlled by the process may be indicated, such as opened files. A history of utilization of the processor or other resources may also be included; this information may be needed by the scheduler.,Process List Stuctures,Processor State Information,Contents of processor registers User-

58、visible registers Control and status registers Stack pointers Program status word (PSW) contains status information Example: the EFLAGS register on Pentium machines,Pentium II EFLAGS Register,Process Context (進程上下文),User-level context: include process program, process data, user stack Register conte

59、xt: include PSW, stack pointer, general-purpose register System-level context: include PCB, memory region table, kernel stack,Process States Process Description Process Control Modes of Execution Process Creation Process Switching Execution of the OS Summary Examples: Process,4. 進程控制和管理,Modes of Execution,User mode Less-privileged mode User programs typically execute in this mode System mode, control mode, or kernel mode More-privileged mode Kernel of the operating system,4.進程的控制和管理,Process States Process Description Process Control Modes of Executio

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論