EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

Threads in Operating System

By Priya PedamkarPriya Pedamkar

Home » Software Development » Software Development Tutorials » Computer Tutorial » Threads in Operating System

Threads in Operating System

Introduction to Threads in Operating System

In this article, we will discuss Threads in Operating System. The execution of process code by tracking the instructions one after the other in the process is called threads. Threads control the process and each thread represents the control of the code. The tasks are run in parallel and it is the subset of the process. We can call threads as a lightweight process or LWP. Different thread does different tasks and the flow of control is separate. Threads can make the application faster by doing different things at the same time. Threads in the same process share the address and memory and are easily accessible whenever needed.

What are Threads?

  • The program is divided into different tasks using threads. These tasks give the illusion of running parallel but are carried out one after the other. Thread has a program counter, registers, and stack. The program counter has the information of all the tasks and the timing, registers save the current working variables and stack stores the history of execution.
  • Information such as code and data related and the open files are shared between threads. When changes are made in one thread, the alterations are seen by other threads as well. Threads in the same process share the memory space and address space.
  • All the threads have a parent process in the execution of codes and no threads run without a process. Servers, be it network or web, run using threads.
  • When processors share the common memory, threads help in doing the parallel execution of processes and programs. Resources needed for threads are less and is always dependent on the process. The threads share the processes and threads and the process is done smoothly. Also, threads share the tasks as if one thread is blocked, the second thread takes up the task.
  • A single thread in the process can read or write or update the details in the other thread. Also, multithreading in the same process requires less memory space than multi-threads in a different process.
  • When a thread takes up the task of other thread or updates the information, OS is not kept informed and all the tasks are done with accuracy.

Types of Threads in Operating System

Threads are classified based on the way they are managed. There are two types of threads.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

1. User Threads

User Threads

These threads are implemented and used in the user library. They cannot be created using the system. While doing thread switching, if the OS is called there will be distractions. The user thread avoids all distractions and does not interrupt the kernel system. These threads are considered as single-threaded processes by the kernel. These are implemented on the systems that do not support multithreading as it is a single thread process. These are simply represented with a single, register, counter and stack. The user threads do not create any separate tasks for creation. The switching is also fast as there is no OS intervention. There is no coordination between threads and kernel and hence if one thread breaks, the entire process is blocked.

2. Kernel Threads

 Kernel Threads

Kernel manages the threads and knows each and every thread. This is a multithreading type. The kernel manages a table to track the threads in each process. Also, there is a separate table to track the processes and update whenever the changes are made. OS makes the changes in the thread while creating and managing them. Knowledge of threads is shared with the kernel and hence the time for each process is scheduled according to the execution. Kernel threads are used for applications that break in between the process. Kernel threads are slow when compared with user threads. The thread control block is needed to control the tasks.

Advantages of Threads in Operating System

Below are the following advantages of threads in OS.

  1. The context switching time is reduced using threads. With traditional methods, it takes longer to switch the contexts between different processes even though they belong to the same OS. This helps in managing the time of the tasks.
  2. While using threads, one task after the other is carried out without being instructed always. Hence concurrency is achieved for the entire process using threads.
  3. Communication between threads and communication between processes is made efficient with the help of threads. This helps to manage the process without being tracking the entire process using a tracker. This reduces costs.
  4. Since it is easy to do context switching, the cost is less and hence the entire process is economical to create and manage and switch the threads between the processes.
  5. Multiprocessors are used in large scale by threads as both have the same characteristics. Building multiprocessor is easy and reliable when compared to other processors.
  6. When multithreading is employed, it responds to the user every now and then and hence customer satisfaction is achieved.

Disadvantages of Threads in Operating System

  1. All the variables both local and global are shared between threads. This creates a security issue as the global variables give access to any process in the system.
  2. When the entire application is dependent on threads, if a single thread breaks, the entire process is broken and blocked. Thus the application is crashed. This particularly happens when the application runs the process with a single thread. When many threads are used, the threads crash each other making the communication difficult.
  3. Threads depend on the system and the process to run. It is not independent. Also, the execution of the process via threads is time-consuming. But processes cannot be run without threads.
  4. Threads are not reusable and it requires more hardware than software due to application changes from the base. Threads cannot be made work without process as they do not have their own address space.

Threads are important to the process and hence to the system. Threads are even used in designing the operating systems. The threads to be used should be carefully determined based on user thread or kernel thread. Safety and security of the codes must be considered as threads share global variables to other threads in the same address space.

Recommended Articles

This is a guide to Threads in Operating System. Here we discuss the basic overview and its types along with the advantages and disadvantages of threads in operating system. You may also have a look at the following articles to learn more –

  1. 32-Bit vs 64-Bit operating system
  2. Cores vs Threads
  3. Functions of Operating System
  4. Multithreading in Operating System

Android Developer Training (40 Courses, 20+ Projects)

40 Online Courses

20 Hands-on Projects

202+ Hours

Verifiable Certificate of Completion

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
Computer Tutorial
  • Computer Basics
    • New Technologies of Computer
    • Application of Computer Graphics
    • Types of Computer Architecture
    • Types of Computer Software
    • Line Drawing Algorithm
    • SOAP Web Services Interview Questions
    • Web Services Interview Questions
    • Microservices Interview Questions
    • What is Windows 10?
    • Windows 10 Desktop Mode
    • Windows Commands  
    • Windows Interview Questions
    • Windows Networking Commands
    • Windows Operators
    • Windows Server Interview Questions
    • Introduction to Windows
    • Top Windows Phone Apps
    • Windows Monitoring Tool
    • Productivity tricks for Windows 10
    • Computer Network Advantages and Disadvantages
    • Computer Network Interview Questions
    • Introduction To Computer Network
    • What is Embedded Systems
    • Components of Embedded System
    • Embedded Systems Security
    • Types of Computer Network
    • Types of Computer Operating System
    • Evolution of Operating System
    • NAS Storage Device
    • Windows Administrator Interview
    • Types of Communication Network
    • What is Automata
    • Types of Mainframe Computers
    • Types of Computer Hardware
    • Types of Sensors
    • What is Server
    • What is RPC
    • What is Microservices
    • Types of Computer Virus
    • Types of Computer Keyboard
    • Types of Motherboard
    • Sensor Device
    • What is Computer Graphic Design
    • Computer Architecture Interview
    • What is Computer Science?
    • What is Bluetooth?
    • What is VLAN?
    • Types of VLAN
    • Types of LAN
    • How does LAN switches work
    • What is VLAN Network?
    • What is Native VLAN?
    • How does LAN Switches work?
    • Switching Modes
    • What is Storage?
    • What is Object Storage?
    • What is Block Storage?
    • Block Level Storage
    • Cordova Local Storage
    • Threads in Operating System
    • What is Gateway?
    • What is Ethernet?
    • What is Virtual Machine?
    • What is a Trunk Port?
    • VPN Applications for Android
    • What is a NAS Drive?
    • What is Ring Topology?
    • Point to Point Topology
    • What is Mesh Topology?
    • Extended Star Topology
    • Token Ring Topology
    • Physical Topology
    • What is a Hybrid Topology?
    • Hybrid Network Topology
    • Star Network Topology
    • Star Bus Topology
    • Zariski Topology
    • Ethernet Topology
    • Logical Topology
    • Partial Mesh Topology
    • Types of Computer Cables
    • Types of Computer Language
    • Features of Operating System
    • Functions of Operating System
    • Multithreading in Operating System
    • Ethernet Frame Format
    • Types of Memory in Computer
    • What is Heap Memory?
    • What is Register?
    • Types of Registers
    • What is Arduino?
    • Arduino Operators
    • What is iSCSI?
    • Computer Science Interview Questions
    • Types of USB Ports
    • What is Port
    • Daisy Chain Network
    • What is a Monitor?
    • What is Printer?
    • Types of Printers
    • What is WPS
    • What is Mouse?
    • Types of Socket
    • Transmission Modes
    • Computers Output Devices
    • Memory Units
    • Secondary Memory
    • What is Memory Card?
    • Types of Memory Cards
    • What is Intranet?
    • Central Processing Unit
    • Computer Ports
    • What is CPU Register
    • Types of CPU
    • Types of Compact Disc
    • Cache Memory Types
    • What is a Motherboard?
    • Types of LED
    • Types of Processor
    • Types of Primary Memory
    • Helpdesk Tool
    • What is Optical Fiber?

Related Courses

Windows 10 Training Course

Java Web Services Training Course

Java Training Course

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA Login

Forgot Password?

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - Android Developer Training (40 Courses, 20+ Projects) Learn More