精華區beta NTU-Exam 關於我們 聯絡資訊
課程名稱︰作業系統 課程性質︰必修 課程教師︰薛智文 開課學院:電資學院 開課系所︰資工系 考試日期(年月日)︰2008.11.6 考試時限(分鐘):180 是否需發放獎勵金:是 (如未明確表示,則不予發放) 試題 : Operating System Name:___________ 902 36700 02, Fall 2008 Score:___/110 ID:_____________ Midterm, November 6th, 9:10 - 12:10 This is an open-book and open-note exam. Please do answer with your own SUCCINCT words in the order of question number in EXACTLY one given answer sheet. You can write in Chinese. You can keep this paper. Good luck. 1.In the implementation of context switch in Linux, why change from using hardware instruction to software function?[10%] 2.What is the purpose of system call?[5%] What kind of system calls are involked if we issue shell command, insmod, to insert kernel module in LUNIX?[5%] 3.A virtual machine provides an interface identical to the underlying bare hardware so that users feel they have a machine of their own. What features the virtual machine can not provide as a real machine?[10%] 4.In a real system, all buffer sizes are limited to physical memory. However, sometimes, we do need an unbounded buffer. Give an example and reason[5%] and describe how it can be implemented?[5%] 5.We use thread pools because usually it is slightly faster to service a request with an existing thread than create a new thread. In what situation, with example, we do not use thread pool? Why?[10%] 6.For the following example, change only one number(<10), so that using SJF and Preemptive SJF both have the same average waiting time. Figure out the number and average waiting time accordingly.[10%] Process Arrival Time Burst Time P1 0.0 7 P2 2.0 3 P3 4.0 1 P4 5.0 4 7.Optimistic Concurrent Control (OCC) approach was proposed to do concurrent control for multiple transactions. The idea behind OCC is "do whatever you want without any locking of resources optimistically; if there is any problem , check it later and roll back if necessary". Is OCC deadlock-free? Why?[5%] What might be the problem of using OCC?[5%] 8.The following is the bakery algorithm to solve multiple processes entering a critical section, where (a,b) < (c,d) means if a < c or if a = c and b < d. In what situation, two different processes get the same number?[5%] What is the purpose of Line 6, while choosing[j] do no-op?[5%] What happen if we delete it?[5%] [Note: Mutual exclusion, deadlock, progressing, starvation...] repeat 1. choosing[i] := true; 2. number[i] := max(number[0], number[1],...,number[n-1]+1) 3. choosing[i] := false; 4. for j := 0 to n-1 5. do begin 6. while choosing[j] do no-op; 7. while number[j] != 0 8. and(number[j],) < (number[i], i) do no-op; 9. end; 10. critical section 11. number[i] = 0; 12. remainder section until false; 9.Find a save sequence if any.[5%] Can request (2,2,0) by P4 be granted?[5%] Find a request of P4 that can be granted at this stage.[5%] Allocation Need Available A B C A B C A B C P0 1 1 0 8 4 3 2 3 1 P1 3 0 1 6 0 0 P2 3 0 2 0 4 0 P3 2 1 1 1 1 0 P4 0 0 2 4 3 1 10.The following program uses two semaphores, first-delay and second-delay, implementing a critical region. Can any requirement of critical regions be released to implement it using only one semaphore, excluding the mutex?[5%] Write a solution for it.[5%] wait(mutex); while(!B){ first-count++; if(second-cout > 0) signal(second-delay); else signal(mutex); wait(first-delay); first-count--; second-count++; if(first-count > 0) signal(first-delay); else signal(second-delay); wait(second-delay); second-count--; } S; if(first-count > 0) signal(first-delay); else if(second-count > 0) signal(second-delay); else signal(mutex); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.91.122
andy74139 :已收錄至精華區!! 11/25 19:02
s864372002 :97上囧 11/25 22:12