
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 exit,
pthread join, and
pthread yield,
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 −
Advantages
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.
Disadvantages
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.