0% found this document useful (0 votes)
6 views3 pages

Threads-User Space, Kernel Space, Hybrid

Uploaded by

Aishu Gowda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Threads-User Space, Kernel Space, Hybrid

Uploaded by

Aishu Gowda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Notes on Implementing threads in user space, implementing threads in the

kernel Hybrid implementations (1.6)

There are three main approaches to implementing threads: user space, kernel
space, and a hybrid combination of both.

1. Implementing threads in User Space

In this approach, the entire threads package resides in user space, without any
direct involvement from the operating system kernel.

advantages:

• User-level threads are lightweight because they don’t require kernel-level


context switches.
• A user-level threads package can be executed on an operating system that
doesn’t inherently support threads.

Disadvantages:

• If one user-level thread blocks (e.g., due to I/O), it blocks all threads within
the process.
• Since user-level threads are managed by the runtime system, they don’t
take full advantage of multiple processors.
2. Implementation of threads in Kernel Space
In this approach, thread management is directly handled by the operating system
kernel.
Advantages:

• Kernel-level threads can run in parallel on multiple processors.


• Blocking of one thread doesn’t affect other threads.

Disadvantages:

• Context switches between kernel threads involve more overhead.


• Limited control over scheduling policies.
• Creation and management of kernel threads require system calls.

Examples: POSIX threads (pthreads) are kernel-level threads.

3. Hybrid Implementations:

These combine elements of both user space and kernel space threads.

Two-Level Hybrid: User-level threads are mapped to kernel threads. User-level


threads are scheduled by the runtime system, which in turn schedules kernel
threads.
User-Level Threads with Kernel Support: User-level threads use kernel
threads for blocking operations (e.g., I/O). This approach mitigates the blocking
issue in pure user-level threads.

In summary, the choice between user space and kernel space threads depends on
trade-offs related to lightweight ness, parallelism, and control. Hybrid approaches
aim to strike a balance between these factors.

You might also like