Life Cycle of Thread in OS

Thread in OS:

A process is divided into several light-weight processes, each light-weight process is said to be a thread. The thread has a program counter that keeps the track of which instruction to execute next, if process registers, which hold its current working variables. It has a stack which contains the executing thread history. The life cycle of thread is  Born state, Ready state, Running state, Blocked State, Sleep, Dead.

The number of threads can share an address space, open files and other resources. The same number of the process can share physical memory, disks, printers and other resources. Because threads have some of the properties of the process. Threads operate in many respects, in the same manner as the process. Threads share the CPU and only one thread at a time is active.

Example of Thread:

Word Processor:

A programmer wish to type the text in word processor. Then the programmer opens a file in a word processor and types the text (It is a thread), and the text is automatically formatted (It is another thread). The text automatically specifies the spelling mistakes (It is another thread), and the file is automatically saved on the disk (It is another thread).
 

Threads

 

Life Cycle of Thread:

1. Born State: A thread that has just been created.
2. Ready State: The thread is waiting for the processor (CPU).
3. Running: The System assigns the processor to the thread means that the thread is being executed.
4. Blocked State: The thread is waiting for an event to occur or waiting for an I/O device.
5. Sleep: A sleeping thread becomes ready after the designated sleep time expires.
6. Dead: The execution of the thread is finished.

Life Cycle of Thread in OS