2022年操作系统期中试卷 3.pdf
《2022年操作系统期中试卷 3.pdf》由会员分享,可在线阅读,更多相关《2022年操作系统期中试卷 3.pdf(4页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、4.1 Provide two programming examples in which multithreading does not provide better performance than a single-threaded solution Answer:(1)Any kind of sequential program is not a good candidate to be threaded.An example of this is a program that calculates an individualtax return.(2)Another example
2、is a shell program such asthe C-shell or Korn shell.Such a program must closely monitor its own working space such as open files,environment variables,and current working directory.4.2 Describe the actions taken by a thread library to context switch between user-level threads.Answer:Context switchin
3、g between user threads is quite similar to switching between kernel threads,although it is dependent on the threads library and how it maps user threads to kernel threads.In general,context switching between user threads involves taking a user thread of its LWP and replacing it with another thread.T
4、his act typically involves saving and restoring the state of the registers.4.3 Under what circumstances does a multithreaded solution using multiple kernel threads provide better performance than a single-threaded solution on a single-processor system?Answer:When a kernel thread suffers a page fault
5、,another kernel thread can be switched in to use the interleaving time in a useful manner.A single-threaded process,on the other hand,will not be capable of performing useful work when a page fault takes place.Therefore,in scenarios where a program might suffer from frequent page faults or has to wa
6、it for other system events,a multi-threaded solution would perform better even on a single-processor system.4.4 Which of the following components of program state are shared across threads in a multithreaded process?a.Register values b.Heap memory c.Global variables d.Stack memory Answer:The threads
7、 of a multithreaded process share heap memory and global variables.Each thread has its separate set of register values and a separate stack.名师资料总结-精品资料欢迎下载-名师精心整理-第 1 页,共 4 页 -4.5 Can a multithreaded solution using multiple user-level threads achieve better performance on a multiprocessor system tha
8、n on a single-processor system?Answer:A multithreaded system comprising of multiple user-level threads cannot make use of the different processors in a multiprocessor system simultaneously.The operating system sees only a single process and will not schedule the different threads of the process on s
9、eparate processors.Consequently,there is no performance benefit associated with executing multiple user-level threads on a multiprocessor system.4.6 As described in Section 4.5.2,Linux does not distinguish between processes and threads.Instead,Linux treats both in the same way,allowing a task to be
10、more akin to a process or a thread depending on the set of flags passed to the clone()system call.However,many operating systems such as Windows XP and Solaris treat processes and threads differently.Typically,such systems use a notation wherein the data structure for a process contains pointers to
11、the separate threads belonging to the process.Contrast these two approaches for modeling processes and threads within the kernel.Answer:On one hand,in systems where processes and threads are considered as similar entities,some of the operating system code could be simplified.A scheduler,for instance
12、,can consider the different processes and threads in equal footing without requiring special code to examine the threads associated with a process during every scheduling step.On the other hand,this uniformity could make it harder to impose process-wide resource constraints in a direct manner.Instea
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年操作系统期中试卷 2022 操作系统 期中 试卷
限制150内