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 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.
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
Benefits
Responsiveness
Resource Sharing
Economy
Scalability
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.

Thread (Operating System)

  • 1.
  • 2.
    What is Thread Athread 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.
  • 3.
    Type of Thread Thereare two type of thread:- Single Thread Multiple thread
  • 4.
    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.
  • 5.
    Multiple thread:- A processwith two threads of execution, running on a single processor
  • 6.
  • 7.
    Responsiveness:- Multithreading an interactiveapplication 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.
  • 8.
    Economy:- cheaper thanprocess 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.
  • 9.
    User Threads andkernel thread User Level Threads -- User managed threads Kernel Level Threads -- Operating System managed threads acting on kernel, an operating system core.
  • 10.
    User Level Threads:- Inthis 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
  • 11.
    Kernel Level Threads:- Threadmanagement 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.
  • 12.
    Multithreading Models Some operatingsystem provide a combined user level thread and Kernel level thread facility. Solaris is a good example of this combined approach.
  • 13.
    Multithreading models arethree types Many to many relationship. Many to one relationship. One to one relationship.
  • 14.
  • 15.
  • 16.
  • 17.
    Difference between UserLevel & 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.
  • 18.
    • User levelthread 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.