A thread is a portion of code that may be executed independently of the main program.
For example, a program may have an open thread waiting for a specific event to occur or running a separate job, allowing the main program to perform other tasks.
A program is capable of having multiple threads...
A thread is a portion of code that may be executed independently of the main program.
For example, a program may have an open thread waiting for a specific event to occur or running a separate job, allowing the main program to perform other tasks.
A program is capable of having multiple threads open at once and will either terminate or suspend them after a task is completed, or the program is closed.
Size: 943.3 KB
Language: en
Added: Jul 14, 2018
Slides: 18 pages
Slide Content
Thread Submitted by Kiran Patel
What is Thread A thread is a portion of code that may be executed independently of the main program . For example, a program may have an open thread waiting for a specific event to occur or running a separate job , allowing the main program to perform other task s. A program is capable of having multiple threads open at once and will either terminate or suspend them after a task is completed, or the program is closed.
Type of Thread There are two type of thread:- Single Thread Multiple thread
Single Thread:- A single-thread, only one task can be done at a time and the program waits until a task is finished before starting another one.
Multiple thread:- A process with two threads of execution, running on a single processor
Responsiveness:- Multithreading an interactive application may allow a program to continue running even if it is blocked or is performing a lengthy operating, increasing responsiveness to the user. Resource Sharing- Thread share resource of process, easier than shared memory or message passing.
Economy:- cheaper than process creation, thread switching lower overhead than context switching. Scalability:- process can take advantage of multiprocessor. The multithreading can be greatly increased in a multiprocessor architecture.
User Threads and kernel thread User Level Threads -- User managed threads Kernel Level Threads -- Operating System managed threads acting on kernel, an operating system core.
User Level Threads:- In this case, application manages thread management kernel is not aware of the existence of threads. The thread library contains code for creating and destroying threads, for passing message and data between threads, for scheduling thread execution
Kernel Level Threads:- Thread management done by the Kernel. There is no thread management code in the application area. Kernel threads are supported directly by the operating system. Any application can be programmed to be multithreaded.
Multithreading Models Some operating system provide a combined user level thread and Kernel level thread facility. Solaris is a good example of this combined approach.
Multithreading models are three types Many to many relationship. Many to one relationship. One to one relationship.
Many to Many Model
Many to One Model
One to One Model
Difference between User Level & Kernel Level Thread User Level Threads User level threads are faster to create and manage . Implementation is by a thread library at the user level. Kernel Level Thread Kernel level threads are slower to create and manage . Operating system supports creation of Kernel threads.
User level thread is generic and can run on any operating system. Multi-threaded application cannot take advantage of multiprocessing. Kernel level thread is specific to the operating system. Kernel routines themselves can be multithreaded.