Life Cycle of Thread in OS
Thread:
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 tracks 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. Same as the number of the process can share physical memory, disks, printers and the 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 typing the text (It is a thread), the text is automatically formatting (It is another thread). The text automatically specifies the spelling mistakes (It is another thread), and the file is automatically saved in the disk (It is another thread).
Life Cycle of Thread:
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.
Recommended Posts:
Operating System
1. Generation of Computer 1st to 5th
2. Memory Hierarchy in Computer Architecture
3. Interrupts in Computer Architecture
4. Cache Memory Mapping Techniques
5. Direct Memory Access in Computer Architecture
6. Functions and Services of OS
7. Major Achievements of OS
8. Types of Operating Systems
9. Characteristics of Modern OS
10. Architecture of Windows and Linux
11. Process States in OS
12. Difference Between Program and Process
13. Process Control Block (PCB) in OS
14. Life Cycle of Thread in OS
15. Difference between User Level Thread and Kernel Level Thread