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

OS03

This chapter discusses threads, including an overview of threads and multithreading models. A thread is a path of execution within a process that allows a process to execute multiple tasks simultaneously. There are three main multithreading models: many-to-one maps many user threads to one kernel thread; one-to-one maps each user thread to a kernel thread; many-to-many allows mapping user threads to kernel threads in a many-to-many ratio. The chapter also covers thread libraries and thread pools that help manage threads.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

OS03

This chapter discusses threads, including an overview of threads and multithreading models. A thread is a path of execution within a process that allows a process to execute multiple tasks simultaneously. There are three main multithreading models: many-to-one maps many user threads to one kernel thread; one-to-one maps each user thread to a kernel thread; many-to-many allows mapping user threads to kernel threads in a many-to-many ratio. The chapter also covers thread libraries and thread pools that help manage threads.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 14

Chapter 3: Threads

Overview
Multithreading Models
Thread Libraries
Thread Pools

Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 1


THREAD
A process is an executing instance of an application. What does
that mean? Well, for example, when you double-click the Microsoft
Word icon, you start a process that runs Word. A thread is a path of
execution within a process. Also, a process can contain multiple
threads. When you start Word, the operating system creates a
process and begins executing the primary thread of that process. A
process can consist of multiple threads, a thread could be
considered a ‘lightweight’ process. A process may contain one or
more threads, but a thread cannot contain a process. a thread is the
smallest unit of processing that can be scheduled by an operating
system. It is also called as process within a process.

Slide 2
Overview
Many software packages are multi-threaded
 Web browser: one thread display images, another thread retrieves data
from the network
 Word processor: threads for displaying graphics, reading keystrokes from
the user, performing spelling and grammar checking in the background
A thread is sometimes called a lightweight process
 A process that has multiples threads can do more than one task at a time
e.g MS world and Web Browser

Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 3


Single and Multithreaded Processes

Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 4


Benefits
Responsiveness
 One part of a program can continue running even if another part is
blocked
Resource Sharing
 Threads of the same process share the same memory space and
resources
Economy
 Much less time consuming to create and manage threads than
processes
Utilization of Multiprocessor Architectures
 Each thread can run in parallel on a different processor

Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 5


Types of Thread
User level Threads
Kernel level Threads

Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 6


User Threads
User level threads are not seen by operating system and are
also very fast. Can be created by users. Web site.
Thread management done by user-level threads library is
without the intervention of the kernel
 Fast to create and manager

Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 7


Kernel Threads
Supported by the Kernel
 Kernel threads are supported by operating system
itself.
 Slower to create and manage than user threads

Examples
- Windows 95/98/NT/2000

Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 8


Multithreading Models
Many-to-One

One-to-One

Many-to-Many

Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 9


Many-to-One
Many user level threads are mapped to one kernel thread. It is efficient because it
is implemented in user space.
A process using this model will be blocked entirely if a thread makes a blocking
system call.
Only one thread can access the kernel at a time so it cannot be run in parallel on
multiprocessor.

Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 10


One-to-One
Each user-level thread maps to kernel thread.
 Another thread can run when one thread makes a blocking call

 Multiple threads can run in parallel on a MP machine

 Overhead of creating a kernel thread for each user thread

 Most implementations limit the number of threads supported

Examples
- Windows 95/98/NT/2000
- OS/2
- Linux

Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 11


Many-to-Many Model
Allows many user level threads to be mapped to smaller or equal
number of kernel threads.
As many user threads as necessary can be created
Corresponding kernel threads can run in parallel on a
multiprocessor
When a thread performs a blocking system call, the kernel can
schedule another thread for execution.
Allows true concurrency in a
MP environment and does not
restrict number of threads that
can be created

Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 12


Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 13
Silberschatz / OS Concepts / 6e - Chapter 5 Threads Slide 14

You might also like