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

Threads & Producer Consumer Problem

Useful for students

Uploaded by

KALPANA DEVI M
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Threads & Producer Consumer Problem

Useful for students

Uploaded by

KALPANA DEVI M
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Threads

Definition
• A thread is a basic unit of CPU utilization; it comprises a thread ID, a
program counter, a register set, and a stack.
• It shares with other threads belonging to the same process its code
section, data section, and other operating-system resources, such as
open files and signals.
• A traditional (or heavyweight) process has a single thread of control.
If a process has multiple threads of control, it can perform more than
one task at a time.
Benefits
• The benefits of multithreaded programming can be broken down into four major
categories:
• Responsiveness. Multithreading an interactive application may allow a program to
continue running even if part of it is blocked or is performing a lengthy operation,
thereby increasing responsiveness to the user.
• Resource sharing. Processes can only share resources through techniques such as
shared memory and message passing.
• Economy. Allocating memory and resources for process creation is costly. Because
threads share the resources of the process to which they belong, it is more
economical to create and contextswitch threads.
• Scalability. The benefits of multithreading can be even greater in a multiprocessor
architecture, where threads may be running in parallel on different processing cores.
Multicore Programming
• Earlier in the history of computer design, in response to the need for
more computing performance, single-CPU systems evolved into multi-
CPU systems.
• A more recent, similar trend in system design is to place multiple
computing cores on a single chip.
• Each core appears as a separate processor to the operating Whether
the cores appear across CPU chips or within CPU chips, we call these
systems multicore or multiprocessor systems.
• Multithreaded programming provides a mechanism for more efficient use
of these multiple computing cores and improved concurrency. Consider an
application with four threads. On a system with a single computing core,
concurrency merely means that the execution of the threads will be
interleaved over time because the processing core is capable of executing
only one thread at a time. On a system with multiple cores, however,
• Concurrency means that the threads can run in parallel, because the system
can assign a separate thread to each core .Notice the distinction between
parallelism and concurrency in this discussion. A system is parallel if it can
perform more than one task simultaneously. In contrast, a concurrent
system supports more than one task by allowing all the tasks to make
progress.

You might also like