THREADS IN OPERATING SYSTEM
A thread is a basic unit of CPU utilization; it comprises a thread ID, a program counter, a register set, and a stack.
It shares with other threads belonging to the same process its code section, data section, and other operating-system resources, such as open files and signals.
Threads share the memory and the resources of the process to which they belong by default.
Single threaded process
A traditional (or heavyweight) process has a single thread of control.
when a process is running a word-processor program, a single thread of instructions is being executed. This single thread of control allows the process to perform only one task at a time.
A single-threaded process has one program counter specifying the next instruction to execute.
The execution of such a process must be sequential. The CPU executes one instruction of the process after another until the process completes.
multithreaded process
If a process has multiple threads of control, it can perform more than one task at a time.
A multithreaded process has multiple program counters, each pointing to the next instruction to execute for a given thread.

Most modern operating systems have extended the process concept to allow a process to have multiple threads of execution and thus to perform more than one task at a time. This feature is especially beneficial on multicore systems, where multiple threads can run in parallel. Most software applications that run on modern computers are multithreaded.
Example:
1. An application typically is implemented as a separate process with several threads of control. A web browser might have one thread display images or text while another thread retrieves data from the network, for example.
2. A word processor may have a thread for displaying graphics, another thread for responding to keystrokes from the user, and a third thread for performing spelling and grammar checking in the background.
Comments
Post a Comment