All Exams Test series for 1 year @ ₹349 only
Question

User level threads are threads that are visible to the programmer and are unknown to the kernel. The operating system kernel supports and manages kernel level threads. Three different types of models relate user and kernel level threads.

Which of the following statements is/are true ?

(a)

(i) The Many - to - one model maps many user threads to one kernel thread

(ii) The one - to - one model maps one user thread to one kernel thread

(iii) The many - to - many model maps many user threads to smaller or equal kernel threads

(b)

(i) Many - to - one model maps many kernel threads to one user thread

(ii) One - to - one model maps one kernel thread to one user thread

(iii) Many - to- many model maps many kernel threads to smaller or equal user threads

The correct answer is

(a) is true; (b) is false

Understanding User and Kernel Level Thread Models

This question asks about the different ways user level threads are mapped to kernel level threads in operating systems. Understanding these thread models is crucial for comprehending how concurrency is managed.

User Level Threads vs. Kernel Level Threads

  • User Level Threads: These are managed by a user-level library without direct kernel involvement. The kernel sees only the process, not the individual user threads within it. They are fast to create and switch between as they don't require system calls or kernel intervention. However, if one user thread makes a blocking system call, the entire process (which is the single unit the kernel knows about) gets blocked, preventing other user threads in the same process from running, even on multi-processor systems.
  • Kernel Level Threads: These are supported and managed directly by the operating system kernel. The kernel is aware of each kernel thread and schedules them independently. If one kernel thread blocks, others belonging to the same process can continue running. This allows for true parallelism on multi-processor systems. However, creating and managing kernel threads involves kernel overhead, making them slower than user threads.

Exploring Thread Mapping Models

There are three primary models that define the relationship between user level threads and kernel level threads:

  1. Many-to-One Model:
  2. In this model, many user level threads are all mapped to a single kernel level thread.
  3. Thread management is handled efficiently in user space.
  4. However, if any user thread performs a blocking system call, the entire process blocks because the single underlying kernel thread blocks.
  5. Multiple user threads cannot run in parallel on multi-processor systems because they are all tied to one kernel thread.
  6. The mapping is best described as $N$ user threads to $1$ kernel thread.
  7. One-to-One Model:
  8. In this model, each user level thread is mapped to its own dedicated kernel level thread.
  9. This provides better concurrency as one blocking user thread does not affect others.
  10. Multiple user threads from the same process can run in parallel on multi-processor systems.
  11. However, this model incurs more overhead as creating a user thread requires creating a corresponding kernel thread.
  12. The mapping is $1$ user thread to $1$ kernel thread.
  13. Many-to-Many Model:
  14. This model maps many user level threads to a smaller or equal number of kernel level threads ($M \le N$).
  15. The number of kernel threads can be specific to the application or the number of available processors.
  16. This model aims to combine the benefits of the Many-to-One (efficiency) and One-to-One (concurrency, non-blocking) models.
  17. The operating system can create enough kernel threads to allow for concurrent execution on multiple CPUs, while the user-level library can efficiently manage many user threads on top of these kernel threads.
  18. The mapping is $N$ user threads to $M$ kernel threads, where $M \le N$.

Analyzing the Statements

Let's evaluate statement (a) and statement (b) based on our understanding of the thread models:

Statement (a):

  • (i) "The Many - to - one model maps many user threads to one kernel thread" - This is true. This accurately describes the Many-to-one mapping ($N:1$).
  • (ii) "The one - to - one model maps one user thread to one kernel thread" - This is true. This accurately describes the One-to-one mapping ($1:1$).
  • (iii) "The many - to - many model maps many user threads to smaller or equal kernel threads" - This is true. This accurately describes the Many-to-many mapping ($N:M$, where $M \le N$).

Since all parts of statement (a) are true based on the standard definitions of thread models, statement (a) as a whole is true.

Statement (b):

  • (i) "Many - to - one model maps many kernel threads to one user thread" - This is false. The Many-to-one model maps many user threads to one kernel thread, not the other way around.
  • (ii) "One - to - one model maps one kernel thread to one user thread" - This statement describes a $1:1$ relationship, but the standard terminology describes the mapping as from user thread to kernel thread ("one user thread to one kernel thread"). While the number ratio is $1:1$, the phrasing is non-standard compared to (a)(ii). However, the core issue here is that statement (b) seems to consistently reverse the direction of mapping compared to the standard descriptions used in statement (a). Considering the clear inaccuracies in (b)(i) and (b)(iii), it's likely this phrasing is intended to represent a reversed mapping perspective, making it contextually false within the structure of statement (b).
  • (iii) "Many - to- many model maps many kernel threads to smaller or equal user threads" - This is false. The Many-to-many model maps many user threads to a smaller or equal number of kernel threads, not the other way around.

Since parts (i), (ii), and (iii) of statement (b) either incorrectly describe the mapping direction or use non-standard phrasing that reverses the common description, statement (b) as a whole is false.

Conclusion

Based on the analysis:

  • Statement (a) is true because all its sub-statements correctly describe the standard thread mapping models from user threads to kernel threads.
  • Statement (b) is false because its sub-statements incorrectly describe the mapping direction or use non-standard phrasing that reverses the common description.

Therefore, (a) is true and (b) is false.

Thread Model Mapping (User : Kernel) Statement (a) Mapping Statement (b) Mapping
Many-to-One N : 1 Many user threads to one kernel thread (True) Many kernel threads to one user thread (False)
One-to-One 1 : 1 One user thread to one kernel thread (True) One kernel thread to one user thread (Less standard phrasing/False in context)
Many-to-Many N : M ($M \le N$) Many user threads to smaller or equal kernel threads (True) Many kernel threads to smaller or equal user threads (False)

Revision Table: User vs. Kernel Thread Models

Feature User Level Threads Kernel Level Threads Many-to-One Model One-to-One Model Many-to-Many Model
Managed by User library Kernel User library & Kernel Kernel User library & Kernel
Kernel Awareness No Yes Partial (only the single kernel thread) Yes (each user thread has a kernel thread) Partial (kernel knows about the M kernel threads)
Creation/Switch Speed Fast Slow Fast (user-level switches) Slow (kernel-level operations) Medium
Blocking Call Impact Blocks entire process Blocks only the calling thread Blocks entire process Blocks only the calling thread Usually blocks only the calling thread (if enough kernel threads)
Parallelism on Multi-CPU No Yes No Yes Yes
Complexity Simpler library More complex kernel User library handles many aspects Kernel handles all aspects Both user library and kernel involvement

Additional Information on Operating System Threading

Threading is a fundamental concept in operating systems that allows a single process to have multiple threads of execution. This enables a program to perform multiple tasks concurrently, improving responsiveness and potentially utilizing multi-processor systems more effectively.

  • Concurrency vs. Parallelism: Concurrency means multiple tasks appear to be running at the same time (achieved by rapid switching, even on a single CPU). Parallelism means multiple tasks are actually running at the exact same time on different processors. Kernel threads are necessary for true parallelism.
  • Process vs. Thread: A process is an instance of a program running, with its own memory space, resources, etc. A thread is a unit of execution within a process. Threads within the same process share the same memory space and resources, making inter-thread communication easier but also requiring careful synchronization.
  • Hybrid Models: Some systems implement variations or hybrid models that combine aspects of the basic types to optimize performance for different workloads.
  • Thread Libraries: Examples of user-level thread libraries include Pthreads (POSIX Threads) and OpenMP. Operating systems like Windows, Linux, and macOS provide kernel-level thread support.
Was this answer helpful?

Important Questions from Thread - Teaching

  1. If an operating system does not allow a child process to exist when the parent process has been terminated, this phenomenon is called as-

  2. Which of the following is not a state of a process in operating system?

  3. Which of the following are not shared by the threads of the same process?

    (a) Stack

    (b) Registers

    (c) Address Space

    (d) Message Queue

  4. Match List-I with List-II

    List – I

    List – II

    (a) Disk

    (i) Thread

    (b) CPU

    (ii) Signal

    (c) Memory

    (iii) File System

    (d) Interrupt

    (iv) Virtual address

    Choose the correct option from those given below:
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App