- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to implement thread in user space?
A thread is a lightweight of process. It is a basic unit of CPU utilization which consists of a program counter, a stack, and a set of registers.
Given below is the structure of single threaded process −
Thread in user space
Now, let us see how to implement thread in User Space.
Step 1 − The complete thread package is placed in the user space and the kernel has no knowledge about it.
Step 2 − Kernel generally, manages ordinary and single threaded processes.
Step 3 − Threads are always run on top of a run-time system.
Step 4 − Run time system is a collection of procedures which manage threads.
For example − pthread create,
pthread join, and
Step 5 − Each process requires its own private thread table to keep track of the threads in that process.
Step 6 − The thread table always keeps a track on each thread’s properties.
Step 7 − The thread tables are managed by the runtime system.
Given below is an image depicting the implementation of thread in user space −
The advantages of implementing thread in user space are as follows −
OSes that do not support thread and thread are implemented by the library.
It doesn’t require any modification in the operating system.
It always gives better performance because there is no context switching involved from the kernel.
Each process has its own scheduling algorithm.
The disadvantages of implementing thread in user space are as follows −
Implementing blocking system calls leads all threads to stop.
If a thread starts running, then no other thread can run unless the thread voluntarily leaves the CPU.
- How to implement thread in kernel space?
- User Thread vs Daemon Thread in Java?
- How to implement user defined exception in Python?
- How can we implement a timer thread in Java?
- Implement Runnable vs Extend Thread in Java
- C# Program to implement Sleep Method Of Thread
- How to get the thread ID from a thread in C#?
- How a thread can interrupt another thread in Java?
- How to create a thread in C#?
- How to create a thread in Java
- How to run continues thread in android?
- How to create a thread in android?
- How to stop AsyncTask thread in android?
- How to stop asynctask thread in Kotlin?
- How to use Thread in Tkinter Python?