Preview

Operating Systems

Satisfactory Essays
Open Document
Open Document
1251 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Operating Systems
Operating Systems
Assignment #5
Of
Chapter 4
Eighth Edition of Operating System Concepts by Avi Silberschatz
Peter Baer Galvin
&
Greg Gagne 2009

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 individual tax return. (2) Another example is a "shell" program such as the 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 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 another 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 suffers 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 page 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. Stack memory

You May Also Find These Documents Helpful