2022年操作系统期中试卷 2.pdf





《2022年操作系统期中试卷 2.pdf》由会员分享,可在线阅读,更多相关《2022年操作系统期中试卷 2.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 exa
2、mple 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: Conte
3、xt switching 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 an
4、other thread. This 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 suf
5、fers a page fault, 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 p
6、age faults or has to wait 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. S
7、tack memory Answer: The threads 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 multithre
8、aded solution using multiple user-level threads achieve better performance on a multiprocessor system than 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
9、 operating system sees only a single process and will not schedule the different threads of the process on separate 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 doe
10、s not distinguish between processes and threads. Instead, Linux treats both in the same way, allowing a task to be 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 th
11、reads differently. Typically, such systems use a notation wherein the data structure for a process contains pointers to 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 a
12、nd threads are considered as similar entities, some of the operating system code could be simplified. A scheduler, for instance, 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 s
13、tep. On the other hand, this uniformity could make it harder to impose process-wide resource constraints in a direct manner. Instead, some extra complexity is required to identify which threads correspond to which process and perform the relevant accounting tasks. 4.7 The program shown in Figure 4.1
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年操作系统期中试卷 2022 操作系统 期中 试卷

限制150内