4.3)
Which of the following components of the program state are shared across threads in a multithreaded process?
a. Register value
b. Heap memory
c. Global variable
d. Stack 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.
4.4)
Output at LINE C is 5. Output at LINE P is 0.
4.6)
What are the two differences between user-level and kernel-level threads? Under what circumstances is one type is better than other?
Answer:
1- User-level threads are unknown by the kernel, whereas the kernel is aware of kernel threads.
2- On systems using either M: 1 or M: N mapping, user threads are scheduled by the thread library and the kernel schedules kernel threads.
3- Kernel threads need not be associated with a process whereas every user thread belongs to a process. Kernel threads are generally more expensive to maintain than user threads as they must be represented with a kernel data structure.
4.9)
Can a multithreaded solution using multiple user-level threads achieve better performance on a multiprocessor system than a single processor system? Explain.
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 separate processors. Consequently, there is no performance benefit associated with executing multiple user-level threads on a multiprocessor system.
4.11)
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,