0% found this document useful (0 votes)
11 views

Lecture_09 - Introduction to Threads

This document provides an introduction to threads in computer architecture and operating systems, explaining their role as paths of execution within processes. It highlights the benefits of multithreading, including improved responsiveness, efficient resource sharing, and enhanced scalability. Additionally, it discusses various multithreading models and the concepts of concurrency and parallelism.

Uploaded by

rajithsjc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lecture_09 - Introduction to Threads

This document provides an introduction to threads in computer architecture and operating systems, explaining their role as paths of execution within processes. It highlights the benefits of multithreading, including improved responsiveness, efficient resource sharing, and enhanced scalability. Additionally, it discusses various multithreading models and the concepts of concurrency and parallelism.

Uploaded by

rajithsjc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Computer Architecture and Operating

Systems
COSC 22073/BECS 22233
Lesson 09: Introduction to Threads
A.M.K.S Aththanayake
Faculty of Science
University of Kelaniya

1
What is a Thread?
A thread is a path of execution within a process. A
process can contain multiple threads.
 Improving the responsiveness of user interfaces.
 Managing concurrent tasks. Threads within the same
process can communicate and share data more easily
than separate processes, which is a significant advantage
in many applications.

2
Why do we need Thread?
 Most modern applications are multithreaded.
 Threads run within the application.
 Multiple tasks with the application can be implemented by separate threads:
 Update display
 Fetch data
 Spell checking
 Answer a network request
 Process creation is heavy-weight while thread creation is light-weight.
 Can simplify code, and increase efficiency.
 Kernels are generally multithreaded

3
Single and Multithreaded Processes

4
Process vs Thread

5
Benefits of Threads
 Concurrency: Threads allow multiple tasks to execute concurrently within the same program, which can lead to better
utilization of available CPU resources and faster task execution. This is particularly important in multi-core and multi-
processor systems.

 Responsiveness: Threads can make applications more responsive. For example, in a graphical user interface, one thread can
handle user input and interface updates, while another thread can perform background tasks like file I/O or network
communication. This prevents the user interface from freezing during resource-intensive operations.

 Efficient Resource Sharing: Threads within the same process share the same memory space and resources, such as file
handles and open network connections. This efficient resource sharing can lead to reduced memory overhead and improved
communication between threads.

 Parallelism: Threads enable parallelism, allowing multiple threads to execute tasks simultaneously. This can significantly
improve the performance of applications that can benefit from dividing their work into smaller, parallel units, such as scientific
simulations, multimedia processing, and data processing..

 Enhanced Scalability: In applications where the workload can vary, threads can be dynamically created and managed to adapt
to the current demand. This scalability can improve the overall efficiency of the application.
. 6
User Threads and Kernel Threads

7
User Threads and Kernel Threads

8
Multithreading Models
Many-to-one
One-to-One
Many-to-Many
Two-level Model

9
Multithreading Models
Many-to-One

10
Multithreading Models
One-to-One

11
Multithreading Models
Many-to-Many

12
Multithreading Models
Two-level Model

13
Multicore Programming

14
Concurrency vs. Parallelism

15
Multicore Programming

16
Data and Task Parallelism

17
Amdahl’s Law

18
Amdahl’s Law
 Speedup = 1 / (S+{(1-S)/N})
= 1/ (0.25 + {(1 - 0.25)/2}
= 1/ (0.25 + 0.375) = 1/ 0.625 = 1.6

19
Thank You.

20

You might also like