精華區beta CSIECourse 關於我們 聯絡資訊
1. In the process state transition diagram, describe an event that causes process state from running to ready and an event that causes process state from running to waiting. a) running to ready : interrupt b) running to waiting: I/O request 2. Consider the following processes, with the process arrival time and the length of CPU burst time units: Arrive Burst P1 0 3 P2 2 2 P3 3 6 P4 7 2 P5 8 5 P6 9 2 What is the average waiting time for FCFS, Preemptive SJF, and RR(Q = 2) Ans: FCFS: (P1,0,3),(P2,3,5),(P3,5,11),(P4,11,13),(P5,13,18),(P6,18,20) AWT = (0+3-1+5-3+11-7+13-8+18-9)/6 PSJF: (P1,0,2),(P1,2,3),(P2,3,5),(P3,5,7),(P4,7,9),(P6,9,11) (P3,11,15),(P5,15,20) AWT = (0-0+2-2+3-2+5-3+7-7+9-9+11-7+15-8)/6 RR(Q=2): a) if the job arrives a little before rescheduling (P1,0,2),(P2,2,4),(P1,4,5),(P3,5,7),(P4,7,9),(P3,9,11) (P5,11,13),(P6,13,15),(P3,15,17),(P5,17,19),(P5,19,20) AWT = (0-0+2-2+4-2+5-3+7-7+9-7+11-8+13-9+15-11+17-13+19-19)/6 b) if the job arrives a little after rescheduling (P1,0,2),(P1,2,3),(P2,3,5),(P3,5,7),(P3,7,9),(P4,9,11) (P5,11,13),(P6,13,15),(P3,15,17),(P5,17,19),(P5,19,20) AWT = (0-0+2-2+3-2+5-3+7-7+9-7+11-8+13-9+15-11+17-13+19-19)/6 3. The Virtual-Machine provides an interface that is identical to underlying bard hardware. Each process executes on it's virtual copy of the underlying computer, (a) What are tha advantages of VM Mechanism? Ans: Security and Researching/Development of OS (b) if VM executes only in physical user mode, how does it support the dual-mode operation appearing in general OS's Ans: VM switch from virtual user mode to virtual monitor mode, save it's states(registers, PC, etc), and change it's state to call physical monitor mode via trap or system call. On the finishing of this physical mode switching, it restore back the states and resume its action. 4. Determination of quantum size in RR and Multilevel Queue scheduling is critical to OS's. Analysis the effect as the quantum size becomes very large or very small. Consider an interactive process, what will be better? large: the algorithms act just like FCFS algorithms, which may let a big program block the CPU small: the algorithms take much time switching. interactive processes are I/O bounded, hence have small CPU-bursts, and should better choose smaller quantums. 5. Generally speaking, there are three levels of schedulers for an OS (Some may be less). Describe the actions and objectives for these schedulers Long-term: moving program from spool to memory. Mid-term: swapping program in or out memory with swapping queue to increase the utilization of CPU by changing the mixture of processes in memory. Short-term: determine which process in memory(ready queue) is next to run 6. Use monitor implementation to solve producer-consumer problem(bounded buf) , use a circular buffer type market = monitor var buf: array [0..N-1] of something; var in, out: integer; var nonfull, nonempty : contidion; procedure entry produce; begin if ((in+1) mod N = out) nonfull.wait; produce_one_item on buf[in]; in := (in+1) mod N; nonempty.signal; end procedure entry consume; begin if (in = out) nonempty.wait; consume_one_item on buf[out]; out := (out+1) mod N; nonfull.signal; end begin in = 0; out = 0; end -- 狐狸說:「你為你的玫瑰耗掉很多時間, 你的玫瑰才變得如此重要!」 「人類已忘掉這個真理,可是你千萬別忘記。 你對自己馴服的東西永遠有責任,你該為你的玫瑰負責。」 -- ※ 發信站: 批踢踢實業坊(ptt.twbbs.org) ◆ From: t199-237.dialup.