SlideShare a Scribd company logo
1 of 3
What is Concurrency?
In computer science, concurrency is the execution of several instruction
sequences at the same time. In an operating system, this happens when there are
several process threads running in parallel. These threads may communicate
with each other through either shared memory or message passing.
Concurrency is the tendency for things to happen at the same time in a system.
Concurrency is a natural phenomenon, of course. In the real world, at any given time,
many things are happening simultaneously. When we design software to monitor and
control real-world systems, we must deal with this natural concurrency.
When dealing with concurrency issues in software systems, there are generally two
aspects that are important: being able to detect and respond to external events
occurring in a random order, and ensuring that these events are responded to in some
minimum required interval.
If each concurrent activity evolved independently, in a truly parallel fashion, this
would be relatively simple: we could simply create separate programs to deal with
each activity. The challenges of designing concurrent systems arise mostly because of
the interactions which happen between concurrent activities. When concurrent
activities interact, some sort of coordination is required.
Multithreading
Many operating systems, particularly those used for real-time applications, offer a
“lighter weight” alternative to processes, called “threads” or “lightweight threads.”
Threads are a way of achieving a slightly finer granularity of concurrency within a
process. Each thread belongs to a single process, and all the threads in a process share
the single memory space and other resources controlled by that process.
Usually each thread is assigned a procedure to execute.
Note: It is unfortunate that the term 'threads' is overloaded. When we use the
word 'thread' by itself, as we do here, we are referring to a 'physical thread'
provided and managed by the operating system. When we refer to a 'thread
of execution', or 'thread of control' or 'timethread' as in the foregoing
discussion, we mean an abstraction which is not necessarily associated with
a physical thread.
Race Conditions:
Perhaps the most fundamental issue of concurrent system design is the avoidance of
“race conditions.” When part of a system must perform state-dependent functions
(that is, functions whose results depend upon the present state of the system), it must
be assured that that state is stable during the operation. In other words, certain
operations must be “atomic.” Whenever two or more threads of control have access to
the same state information, some form of “concurrency control” is necessary to assure
that one thread does not modify the state while the other is performing an atomic
state-dependent operation. Simultaneous attempts to access the same state information
which could make the state internally inconsistent are called “race conditions.”
A typical example of a race condition could easily occur in the elevator system when
a floor is selected by a passenger. Our elevator works with lists of floors to be visited
when traveling in each direction, up and down. Whenever the elevator arrives at a
floor, one thread of control removes that floor from the appropriate list and gets the
next destination from the list. If the list is empty, the elevator either changes direction
if the other list contains floors, or goes idle if both lists are empty. Another thread of
control is responsible for putting floor requests in the appropriate list when the
passengers select their floors. Each thread is performing combinations of operations
on the list which are not inherently atomic: for example, checking the next available
slot then populating the slot. If the threads happen to interleave their operations, they
can easily overwrite the same slot in the list.
What is concurrency

More Related Content

Viewers also liked

Viewers also liked (20)

Java8 training - class 3
Java8 training - class 3Java8 training - class 3
Java8 training - class 3
 
Java8 training - Class 1
Java8 training  - Class 1Java8 training  - Class 1
Java8 training - Class 1
 
Java8 training - class 2
Java8 training - class 2Java8 training - class 2
Java8 training - class 2
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with java
 
Building Applications with a Graph Database
Building Applications with a Graph DatabaseBuilding Applications with a Graph Database
Building Applications with a Graph Database
 
Java8
Java8Java8
Java8
 
Jumping-with-java8
Jumping-with-java8Jumping-with-java8
Jumping-with-java8
 
Apache camel
Apache camelApache camel
Apache camel
 
Java Hands-On Workshop
Java Hands-On WorkshopJava Hands-On Workshop
Java Hands-On Workshop
 
Concurrency & Parallel Programming
Concurrency & Parallel ProgrammingConcurrency & Parallel Programming
Concurrency & Parallel Programming
 
Comparison of scheduling algorithms
Comparison of scheduling algorithmsComparison of scheduling algorithms
Comparison of scheduling algorithms
 
Java day2016 "Reinventing design patterns with java 8"
Java day2016 "Reinventing design patterns with java 8"Java day2016 "Reinventing design patterns with java 8"
Java day2016 "Reinventing design patterns with java 8"
 
Why Transcriptome? Why RNA-Seq? ENCODE answers….
Why Transcriptome? Why RNA-Seq?  ENCODE answers….Why Transcriptome? Why RNA-Seq?  ENCODE answers….
Why Transcriptome? Why RNA-Seq? ENCODE answers….
 
Java Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and TrendsJava Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and Trends
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and Concurrency
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Java Concurrency in Practice
Java Concurrency in PracticeJava Concurrency in Practice
Java Concurrency in Practice
 
Working With Concurrency In Java 8
Working With Concurrency In Java 8Working With Concurrency In Java 8
Working With Concurrency In Java 8
 
dna Imprinting
 dna Imprinting dna Imprinting
dna Imprinting
 
JAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsJAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp concepts
 

Similar to What is concurrency

Processscheduling 161001112521
Processscheduling 161001112521Processscheduling 161001112521
Processscheduling 161001112521
marangburu42
 
A METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOB...
A METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOB...A METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOB...
A METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOB...
ijsc
 
METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOBIL...
METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOBIL...METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOBIL...
METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOBIL...
ijsc
 
A Metaheuristic Optimization Algorithm for the Synchronization of Chaotic Mob...
A Metaheuristic Optimization Algorithm for the Synchronization of Chaotic Mob...A Metaheuristic Optimization Algorithm for the Synchronization of Chaotic Mob...
A Metaheuristic Optimization Algorithm for the Synchronization of Chaotic Mob...
ijsc
 
Processscheduling 161001112521
Processscheduling 161001112521Processscheduling 161001112521
Processscheduling 161001112521
marangburu42
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
kansel85
 
INTERACTIVITY and EM..
INTERACTIVITY and EM..INTERACTIVITY and EM..
INTERACTIVITY and EM..
butest
 
INTERACTIVITY and EM..
INTERACTIVITY and EM..INTERACTIVITY and EM..
INTERACTIVITY and EM..
butest
 

Similar to What is concurrency (20)

Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Process coordination
Process coordinationProcess coordination
Process coordination
 
Osonto documentatie
Osonto documentatieOsonto documentatie
Osonto documentatie
 
Processscheduling 161001112521
Processscheduling 161001112521Processscheduling 161001112521
Processscheduling 161001112521
 
Presentation transaction
Presentation transactionPresentation transaction
Presentation transaction
 
A METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOB...
A METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOB...A METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOB...
A METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOB...
 
METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOBIL...
METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOBIL...METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOBIL...
METAHEURISTIC OPTIMIZATION ALGORITHM FOR THE SYNCHRONIZATION OF CHAOTIC MOBIL...
 
A Metaheuristic Optimization Algorithm for the Synchronization of Chaotic Mob...
A Metaheuristic Optimization Algorithm for the Synchronization of Chaotic Mob...A Metaheuristic Optimization Algorithm for the Synchronization of Chaotic Mob...
A Metaheuristic Optimization Algorithm for the Synchronization of Chaotic Mob...
 
Processscheduling 161001112521
Processscheduling 161001112521Processscheduling 161001112521
Processscheduling 161001112521
 
Processscheduling 161001112521
Processscheduling 161001112521Processscheduling 161001112521
Processscheduling 161001112521
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
 
Dbms voc 5 unit
Dbms voc 5 unitDbms voc 5 unit
Dbms voc 5 unit
 
Load Balancing.pptx
Load Balancing.pptxLoad Balancing.pptx
Load Balancing.pptx
 
INTERACTIVITY and EM..
INTERACTIVITY and EM..INTERACTIVITY and EM..
INTERACTIVITY and EM..
 
INTERACTIVITY and EM..
INTERACTIVITY and EM..INTERACTIVITY and EM..
INTERACTIVITY and EM..
 
Ho20
Ho20Ho20
Ho20
 
Vveis03
Vveis03Vveis03
Vveis03
 
Bt0070 operating systems 1
Bt0070 operating systems  1Bt0070 operating systems  1
Bt0070 operating systems 1
 
Process synchronizationfinal
Process synchronizationfinalProcess synchronizationfinal
Process synchronizationfinal
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 

What is concurrency

  • 1. What is Concurrency? In computer science, concurrency is the execution of several instruction sequences at the same time. In an operating system, this happens when there are several process threads running in parallel. These threads may communicate with each other through either shared memory or message passing. Concurrency is the tendency for things to happen at the same time in a system. Concurrency is a natural phenomenon, of course. In the real world, at any given time, many things are happening simultaneously. When we design software to monitor and control real-world systems, we must deal with this natural concurrency. When dealing with concurrency issues in software systems, there are generally two aspects that are important: being able to detect and respond to external events occurring in a random order, and ensuring that these events are responded to in some minimum required interval. If each concurrent activity evolved independently, in a truly parallel fashion, this would be relatively simple: we could simply create separate programs to deal with each activity. The challenges of designing concurrent systems arise mostly because of the interactions which happen between concurrent activities. When concurrent activities interact, some sort of coordination is required.
  • 2. Multithreading Many operating systems, particularly those used for real-time applications, offer a “lighter weight” alternative to processes, called “threads” or “lightweight threads.” Threads are a way of achieving a slightly finer granularity of concurrency within a process. Each thread belongs to a single process, and all the threads in a process share the single memory space and other resources controlled by that process. Usually each thread is assigned a procedure to execute. Note: It is unfortunate that the term 'threads' is overloaded. When we use the word 'thread' by itself, as we do here, we are referring to a 'physical thread' provided and managed by the operating system. When we refer to a 'thread of execution', or 'thread of control' or 'timethread' as in the foregoing discussion, we mean an abstraction which is not necessarily associated with a physical thread. Race Conditions: Perhaps the most fundamental issue of concurrent system design is the avoidance of “race conditions.” When part of a system must perform state-dependent functions (that is, functions whose results depend upon the present state of the system), it must be assured that that state is stable during the operation. In other words, certain operations must be “atomic.” Whenever two or more threads of control have access to the same state information, some form of “concurrency control” is necessary to assure that one thread does not modify the state while the other is performing an atomic state-dependent operation. Simultaneous attempts to access the same state information which could make the state internally inconsistent are called “race conditions.” A typical example of a race condition could easily occur in the elevator system when a floor is selected by a passenger. Our elevator works with lists of floors to be visited when traveling in each direction, up and down. Whenever the elevator arrives at a floor, one thread of control removes that floor from the appropriate list and gets the next destination from the list. If the list is empty, the elevator either changes direction if the other list contains floors, or goes idle if both lists are empty. Another thread of control is responsible for putting floor requests in the appropriate list when the passengers select their floors. Each thread is performing combinations of operations on the list which are not inherently atomic: for example, checking the next available slot then populating the slot. If the threads happen to interleave their operations, they can easily overwrite the same slot in the list.