Introdution and objectives of Thread.pptx

viceprincipalbfc 12 views 4 slides Sep 01, 2024
Slide 1
Slide 1 of 4
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4

About This Presentation

Introdution and objectives of Thread.pptx


Slide Content

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 Process called as heavy weight process Process run in separate memory space Processes are independent of each other Processes share physical memory, disks, printers etc. Process requires more recourses to execute. Hence it is called heavy weight process. Implementing the communication between processes is a bit more difficult. Context switching between two processes are time consuming A process without multiple threads has slow response time Threads are called light weight processes Threads within the same process run I a shared memory space Threads are not independent of one another Threads share with other threads their code section, data section, OS recourses like open files etc. Threads require fewer recourses to execute. Hence it is called light weight processes. Communication between two threads are easy to implement because threads share common address space. Context switching between two threads are less time consuming If the process is divided into multiple threads, if one thread complete its execution then its output can be immediately returned (Faster response)