Module-1 1
Module-1 1
THREADS
TOPICS
Process Concept
Process Scheduling
Operations on Processes
Cooperating Processes
Interprocess Communication
Introduction to Threads
Single and Multi-threaded processes and its benefits
User and Kernel threads
Multithreading models
PROCESS CONCEPT
Process Thread
Process is heavy weight. light weight taking lesser
resources than a process.
Process switching needs
interaction with operating Thread switching does not
system. need to interact with operating
system.
Multiple processes without
using threads use more Multiple threaded processes
resources. use fewer resources.
If one process is blocked While one thread is blocked
then no other process can another thread can run.
execute until the first One thread can read, write or
process is unblocked. change another thread's data.
In multiple processes each
process operates
independently of the others.
SINGLE AND MULTITHREADED
PROCESSES
BENEFITS OF MULTITHREADED
PROGRAMMING
One-to-One
Many-to-Many
MANY-TO-ONE
Many user-level threads mapped to single kernel thread
Thread management is done in user space
entire process will block if a thread makes a blocking system
call
only one thread can access the kernel at a time, multiple
threads are unable to run in parallel on multiprocessors
Examples:
⚫ Solaris Green Threads
⚫ GNU Portable Threads
MANY-TO-ONE MODEL
ONE-TO-ONE
Each user-level thread maps to kernel thread
Provides more concurrency than the many-to-one model by
allowing another thread to run when a thread makes a blocking
system call
Allows multiple threads to run in parallel on multiprocessors
creating a user thread requires creating the corresponding kernel
thread
Examples
⚫ Windows NT/XP/2000
⚫ Linux
⚫ Solaris 9 and later
ONE-TO-ONE MODEL
MANY-TO-MANY MODEL
Allows many user level threads to be mapped to a smaller or
equal number of kernel threads
Allows the operating system to create a sufficient number of
kernel threads
corresponding kernel threads can run in parallel on a
multiprocessor
Solaris prior to version 9
Windows NT/2000 with the ThreadFiber package
MANY-TO-MANY MODEL
TWO-LEVEL MODEL
Similar to M:M, except that it allows a user thread to be
bound to kernel thread
Examples
⚫ IRIX
⚫ HP-UX
⚫ Tru64 UNIX
⚫ Solaris 8 and earlier
TWO-LEVEL MODEL