Threads in Operating System

Threads in operating system
Process and Threads

Practice MCQ Questions of Operating System

Practice Now

What is Thread?

A process divided into a number of lightweight processes, and each lightweight process is said to be a thread. The thread has a program counter that keeps the tracks of which instruction to execute next. It has registers, which hold current working variables. It has a stack, which contains the execution history.

The number of threads can share an address space, open files, and other resources. Threads operate in many respects, in the same manner as processes. Threads can be in one of the several states: Ready, Blocked, Running and Terminated.

Like the process, threads share the CPU and only one thread at a time is active(Running). Threads can create child threads. Unlike process, threads are not independent of one another because all threads access every address in the task. A thread can read or write over any other thread stack.

Each thread designating portion of the program that may be executed concurrently with other threads. This capability is called multithreading.


Examples of thread in OS

Word processor is an example of a thread. A programmer wishes to type the text in the word processor, then the programmer opens a file in the word processor, and type text(It is one thread). The text is automatically formatting (It is another thread). And the file is automatically saved in the disk(It is another thread). Typing in a file is a process, but typing formatting, spell checking and scanning are threads.


Thread Life Cycle in OS

Lifecycle of Thread, Thread States in Operating System
Lifecycle of thread

I hope you have cleared about threads in the operating system.