In: Computer Science
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 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 the separate threads belonging to the process.
Contrast these two approaches for modeling processes and threads within the kernel. Consider a multiprocessor system and a multithreaded program written using the many-to-many threading model. Let the number of user-level threads in the program be more than the number of processors in the system. Discuss the performance implications of the following scenarios.
On one hand, in systems whereprocesses and threads are considered as similar entities, some of the operating system codecould be simplified. A scheduler, for instance, can consider the different processes and threadsin equal footing without requiring special code to examine the threads associated with aprocess during every scheduling step. On the other hand, this uniformity could make it harderto 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 therelevant accounting tasks.
And if we are considering a multiprocessor system and a multithreaded program written using the many-to-many threading model. Let the number of user-level threads in the program be more than the number of processors in the system. Discuss the performance implications of the following scenarios:
a. The number of kernel threads allocated to the program is less than the number of processors. The scheduler can only schedule user level processes to the kernel threads, and since some of the processes are not mapped to the kernel threads, they will be idle.
b. The number of kernel threads allocated to the program is greater than the number of processors but less than the number of user-level threads. All of the processes will be working simultaneously assuming there are enough user threads. If a kernel thread is blocked, it may be swapped out for one that isn’t blocked.