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/cn.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灯, 水草

请输入看板名称,例如:BabyMother站内搜寻

TOP