Operating System Exercises - Chapter 4 Sol
Operating System Exercises - Chapter 4 Sol
Operating System Exercises - Chapter 4 Sol
CHAPTER
Threads
Practice Exercises
requires allocating a process control block (PCB), a rather large data struc-
ture. The PCB includes a memory map, list of open files, and environ-
ment variables. Allocating and managing the memory map is typically
the most time-consuming activity. Creating either a user or kernel thread
involves allocating a small data structure to hold a register set, stack, and
priority.
4.5 Assume an operating system maps user-level threads to the kernel us-
ing the many-to-many model and the mapping is done through LWPs.
Furthermore, the system allows developers to create real-time threads.
Is it necessary to bind a real-time thread to an LWP? Explain.
Answer: Yes. Timing is crucial to real-time applications. If a thread is
marked as real-time but is not bound to an LWP, the thread may have
to wait to be attached to an LWP before running. Consider if a real-time
thread is running (is attached to an LWP) and then proceeds to block (i.e.
must perform I/O, has been preempted by a higher-priority real-time
thread, is waiting for a mutual exclusion lock, etc.) While the real-time
thread is blocked, the LWP it was attached to has been assigned to another
thread. When the real-time thread has been scheduled to run again, it
must first wait to be attached to an LWP. By binding an LWP to a real-
time thread you are ensuring the thread will be able to run with minimal
delay once it is scheduled.
4.6 A Pthread program that performs the summation function was provided
in Section 4.3.1. Rewrite this program in Java.
Answer: Please refer to the supporting Web site for source code solution.