b04902xxx 板


LINE

※ [本文轉錄自 NTU-Exam 看板 #1LVuZjda ] 作者: rod24574575 (天然呆) 看板: NTU-Exam 標題: [試題] 103下 郭大維 作業系統 期中考+解答 時間: Tue Jun 16 10:24:42 2015 課程名稱︰作業系統 課程性質︰選修 課程教師:郭大維 開課學院:電資學院 開課系所︰資工系 考試日期(年月日)︰2015.05.13 考試時限(分鐘):180分鐘 試題 : Operating Systems Mid-Term Spring 2015 The exam is 180 minutes long. The total score is 108pts. Please read the questions carefully. 1. Terminologies (24pts). a. Buffering (Hint: It is not caching.) Ans: It means to keep data in a faster medium temporarily before moving them to a slower layer. b. Virtual Machine Ans: It provides an interface that is identical to the underlying bare hardware. c. System Generation (SYSGEN) Ans: The process to configure or generate an operating system for a one specific computer. d. Context Switch Ans: Save the state of the old process and load the state of the newly scheduled process. e. Remote Procedure Call (Hint: Message Passing) Ans: Senders are blocked until the receivers have received msgs and replied by reply msgs. (A way to abstract the procedure-call mechanism for use between systems with network connection.) f. Implicit Threading Ans: Transfer the creation and management of the threading from the application developers to compilers and run-time libraries. g. Earliest Deadline First Scheduling Ans: A dynamic-priority real-time process scheduling algorithm in which the priorities of processes are higher if their deadlines are closer. h. Race Condition Ans: A situation where the outcome of the execution depends on the particular order of process scheduling. 2. Please answer the following questions regarding the designs of operating systems: (22pts) a. An operating system could be considered as a resource allocator. Please list 3 resources managed by an operating systems. (6pts) b. Please explain what happens to the operating system when an interrupt arrives (until the interrupt is serviced). (4pts) c. Which one of the following instructions is a privileged instruction: Reading of the Timer, setting of the base register of the memory space of a process, increment the value of a CPU register by one. No explanation is needed. (6pts) d. Please explain what happens when a command-line user interface of Unix executes a command. (6pts) Ans: (a) CPU, files, memory. (b) Saving of the address of the interrupted instruction, determine the interrupt type (by polling or interrupt vector), call the corresponding handlers. (c) Setting of the base register of the memory space of a process. (d) Search the exec file which corresponds to the command; fork a process to execute the file. 3. Consider parameter passing to a system call. Give me the major advantage in having a register pointing to a memory block that stores all parameters, compared to having all parameters stored in registers? (5pts) Ans: The space needed to store all parameters is virtually unlimited. 4. The memory image of a Unix process might consist of a code segment, a data segment, a heap area, a user stack, a kernel stack, an environment variable area, and .u. Which one of the above is used when malloc() is invoked? When the kernel stack is used? (8pts) Ans: (a) heap (b) procedure invocation in the system mode. 5. Please explain how fork() works when a parent process invoke fork(). Please use the answer to the fork() invocation to explain the difference between fork() and vfork(). (10pts) Ans: (1) When a parent process invoke fork(), a duplication of the parent process is created for the resulted child process, where the parent process returns from fork() with the process ID of the created child process. The child process returns 0. (2) When a parent process invoke vfork(), a child process is created by using the process image of the parent process, including its code and data segments. However, the parent process stop temporarily until the child process invokes an execve()-like system call to start a new program or terminates. The child process can modify any contents of the data segment of the parent process. 6. In the multi-core age, threading is encouraged. Please answer the following questions: (8pts) a. For multiple cores, do we prefer kernel-level threads or user-level threads? Why? (3pts) b. There are also challenges in programming. Consider merge sorting, in which an unsorted list is divided into N sublists, each containing 1 element, and then we repeatedly merge sublists to produce new sorted sublists until there is only 1 sublist remaining. This will be the sorted list. Please use the concept of task parallelism to execute the merge sort over N cores. (5pts) Ans: (a) Kernel-level threads are preferred because more than one threads could be running at the same time. (b) Each core is given a sublist of one element. We then group 2 adjacent cores and let one of the cores merge the sublists of the two cores. …… 7. Please answer the following questions for process scheduling. Explanation is needed to receive any credit. (15pts) a. Given 5 processes P1, P2, P3, P4, and P5 with CPU burst time 6, 5, 2, 10, 5, respectively. Suppose that the P1, P2, P3, P4, and P5 arrive at time 0, 3, 4, 2, and 5, respectively. What is the average waiting time in running the 5 processes under the Preemptive Shortest-Job-First Scheduling. (5pts) b. Consider Shortest-Job-First Scheduling and Round-Robin Scheduling. Please prove that the total waiting time in running all processes under Shortest-Job-First Scheduling is always no larger than that of Round-Robin Scheduling with time slice equal to 1 when all processes are ready at time 0? (5pts) c. Suppose that the variance of the waiting time is the criterion in process scheduling. Shall we have a small time slice for a better variance for Round-Robin Scheduling when all processes of the same CPU burst arrive at time 0? (5pts) Ans: (a) 31/5 (b) Yes. Proof... (c) Yes. Proof... 8. Please answer the following questions for process synchronization: (l6pts) a. Please compare the difference between a binary semaphore and a condition variable. (3pts) b. Please use Monitor to implement Consumer and Producer with a bounded buffer. (10pts) c. Please prove that your above solution satisfy the Progress requirement of the Critical Section Problem. (3pts) Ans: (A) signal invotion to a condition variable that has no pending process has no effect. (b) monitor ProducerConsumer { int nfull = 0; cond has_empty, has_full; producer() { if(nfull == N) wait(has_empty); ... // fill a slot ++nfull; signal(has_full); } consumer() { if(nfull == 0) wait(has_full); ... // empty a slot --nfull; signal(has_empty); } }; Two condition variables: ‧ has_empty: buffer has at least one empty slot ‧ has_full: buffer has at least one full slot nfull: number of filled slots ‧ Need to do our own counting for condition variables. (c) Skipped. --



※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.24.74.155
※ 文章網址: https://webptt.com/m.aspx?n=bbs/NTU-Exam/M.1434421485.A.9E4.html
1F:→ rod24574575 : 已收資訊系! 06/16 10:26



※ 發信站: 批踢踢實業坊(ptt.cc)
※ 轉錄者: w4a2y4 (140.112.16.131), 05/01/2017 16:20:28







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:BuyTogether站內搜尋

TOP