Threads
 A thread (or lightweight process) is a basic unit of CPU utilization;
it consists of:
 program counter
 register set
 stack space
 A thread shares with its peer threads its:
 code section
 data section
 operating-system resources
collectively know as a task.
 A traditional or heavyweight process is equal to a task with one
thread
Threads (Cont.)
 In a multiple threaded task, while one server thread is blocked
and waiting, a second thread in the same task can run.
 Cooperation of multiple threads in same job confers higher throughput
and improved performance.
 Applications that require sharing a common buffer (i.e., producer-
consumer) benefit from thread utilization.
 Threads provide a mechanism that allows sequential processes to
make blocking system calls while also achieving parallelism.
 Kernel-supported threads (Mach and OS/2).
 User-level threads; supported above the kernel, via a set of library
calls at the user level (Project Andrew from CMU).
 Hybrid approach implements both user-level and kernel-supported
threads (Solaris 2).
Multiple Threads within a
Task
Process Vs. Thread
1. Process called as heavy weight
process
2. Process run in separate memory space
3. Processes are independent of each
other
4. Processes share physical memory,
disks, printers etc.
5. Process requires more recourses to
execute. Hence it is called heavy
weight process.
6. Implementing the communication
between processes is a bit more
difficult.
7. Context switching between two
processes are time consuming
8. A process without multiple threads
has slow response time
1. Threads are called light weight processes
2. Threads within the same process run I a
shared memory space
3. Threads are not independent of one another
4. Threads share with other threads their code
section, data section, OS recourses like
open files etc.
5. Threads require fewer recourses to
execute. Hence it is called light weight
processes.
6. Communication between two threads are
easy to implement because threads share
common address space.
7. Context switching between two threads are
less time consuming
8. If the process is divided into multiple
threads, if one thread complete its
execution then its output can be
immediately returned (Faster response)

Introdution and objectives of Thread.pptx

  • 1.
    Threads  A thread(or lightweight process) is a basic unit of CPU utilization; it consists of:  program counter  register set  stack space  A thread shares with its peer threads its:  code section  data section  operating-system resources collectively know as a task.  A traditional or heavyweight process is equal to a task with one thread
  • 2.
    Threads (Cont.)  Ina multiple threaded task, while one server thread is blocked and waiting, a second thread in the same task can run.  Cooperation of multiple threads in same job confers higher throughput and improved performance.  Applications that require sharing a common buffer (i.e., producer- consumer) benefit from thread utilization.  Threads provide a mechanism that allows sequential processes to make blocking system calls while also achieving parallelism.  Kernel-supported threads (Mach and OS/2).  User-level threads; supported above the kernel, via a set of library calls at the user level (Project Andrew from CMU).  Hybrid approach implements both user-level and kernel-supported threads (Solaris 2).
  • 3.
  • 4.
    Process Vs. Thread 1.Process called as heavy weight process 2. Process run in separate memory space 3. Processes are independent of each other 4. Processes share physical memory, disks, printers etc. 5. Process requires more recourses to execute. Hence it is called heavy weight process. 6. Implementing the communication between processes is a bit more difficult. 7. Context switching between two processes are time consuming 8. A process without multiple threads has slow response time 1. Threads are called light weight processes 2. Threads within the same process run I a shared memory space 3. Threads are not independent of one another 4. Threads share with other threads their code section, data section, OS recourses like open files etc. 5. Threads require fewer recourses to execute. Hence it is called light weight processes. 6. Communication between two threads are easy to implement because threads share common address space. 7. Context switching between two threads are less time consuming 8. If the process is divided into multiple threads, if one thread complete its execution then its output can be immediately returned (Faster response)