Threads | Operating System - Computer Science Engineering (CSE) PDF Download

A thread is a single sequence stream within a process. Threads are also called lightweight processes as they possess some of the properties of processes. Each thread belongs to exactly one process. In an operating system that supports multithreading, the process can consist of many threads. But threads can be effective only if the CPU is more than 1 otherwise two threads have to context switch for that single CPU.

What is Thread in Operating Systems?

In a process, a thread refers to a single sequential activity being executed. these activities are also known as thread of execution or thread control. Now, any operating system process can execute a thread. we can say, that a process can have multiple threads.

Why Do We Need Thread?

  • Threads run in parallel improving the application performance. Each such thread has its own CPU state and stack, but they share the address space of the process and the environment. 
  • Threads can share common data so they do not need to use inter-process communication. Like the processes, threads also have states like ready, executing, blocked, etc. 
  • Priority can be assigned to the threads just like the process, and the highest priority thread is scheduled first.
  • Each thread has its own Thread Control Block (TCB). Like the process, a context switch occurs for the thread, and register contents are saved in (TCB). As threads share the same address space and resources, synchronization is also required for the various activities of the thread.

Components of Threads

These are the basic components of the Operating System.

  • Stack Space
  • Register Set
  • Program Counter

Types of Thread in Operating System

Threads are of two types. These are described below.

  • User Level Thread 
  • Kernel Level Thread

User Level thread Vs Kernel Level thread

Threads | Operating System - Computer Science Engineering (CSE)

Multi threading models

Many operating systems support kernel thread and user thread in a combined way. Example of such system is Solaris. Multi threading model are of three types.

Many to many model.
Many to one model.
one to one model.

Many to Many Model

In this model, we have multiple user threads multiplex to same or lesser number of kernel level threads. Number of kernel level threads are specific to the machine, advantage of this model is if a user thread is blocked we can schedule others user thread to other kernel thread. Thus, System doesn’t block if a particular thread is blocked.

Threads,Operating System,GATE,CSE,ITE

Many to One Model

In this model, we have multiple user threads mapped to one kernel thread. In this model when a user thread makes a blocking system call entire process blocks. As we have only one kernel thread and only one user thread can access kernel at a time, so multiple threads are not able access multiprocessor at the same time.

Threads,Operating System,GATE,CSE,ITE

One to One Model

In this model, one to one relationship between kernel and user thread. In this model multiple thread can run on multiple processor. Problem with this model is that creating a user thread requires the corresponding kernel thread.

Threads,Operating System,GATE,CSE,ITE

The document Threads | Operating System - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Operating System.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
10 videos|99 docs|33 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Threads - Operating System - Computer Science Engineering (CSE)

1. What is a thread in operating systems?
Ans. A thread in operating systems is the smallest unit of execution within a process. It represents a single sequence of execution within a program.
2. Why do we need threads in operating systems?
Ans. Threads are needed in operating systems to allow for concurrent execution of multiple tasks within a single process, improving performance and responsiveness.
3. What are the components of a thread?
Ans. The components of a thread include a program counter, stack, and thread ID. Each thread shares the code section and data section with other threads in the same process.
4. What are the types of threads in an operating system?
Ans. The types of threads in an operating system include user-level threads, which are managed by the application, and kernel-level threads, which are managed by the operating system.
5. What is the difference between user-level threads and kernel-level threads?
Ans. User-level threads are managed by the application and do not require kernel support for thread management, while kernel-level threads are managed by the operating system and have full support for multi-threading operations.
10 videos|99 docs|33 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Threads | Operating System - Computer Science Engineering (CSE)

,

Sample Paper

,

Free

,

Threads | Operating System - Computer Science Engineering (CSE)

,

Important questions

,

pdf

,

Viva Questions

,

shortcuts and tricks

,

video lectures

,

Threads | Operating System - Computer Science Engineering (CSE)

,

Extra Questions

,

Objective type Questions

,

Previous Year Questions with Solutions

,

Exam

,

ppt

,

Semester Notes

,

past year papers

,

mock tests for examination

,

practice quizzes

,

Summary

,

MCQs

,

study material

;