SlideShare a Scribd company logo
CONCURRENT PROGRAMING
AND COMPONENTS
CHAPTER GOALS
 Understand why concurrent programming is
important.
 Give a working definition of concurrent program.
 Understand the two types of synchronization and
give examples of each.
CHAPTER GOALS
 Give a definition of the term component and
know what special problems can be encountered
when using components.
 Describe several different reasons for doing
concurrent programming and how each of these
reasons leads to different design decisions and
different program implementation.
WHAT IS CONCURRENT PROGRAMMING ?
 The purpose of this course is to help the
students understand how to create
concurrent programs with special concurrent
object, called concurrent components.
 This components are used only in
concurrent programs.
WHAT IS CONCURRENT PROGRAMMING ?
 A good definition of a concurrent program is needed
before components can be defined and methods given
for their implementation.
 This chapter provides a good working definition of a
concurrent program after explaining why concurrent
programming is important concept for programmer to
know.
WHAT IS CONCURRENT PROGRAMMING ?
 The working definition of a concurrent
program provided here will serve as a basis
for understand concurrent programming
throughout the course.
WHAT IS CONCURRENT PROGRAMMING ?
 The definition of an asynchronous activity
leads to very simple definition of
concurrency:
Concurrency is defined as the presence of
two or more asynchronous activities.
ASYNCHRONOUS ACTIVITIES
 Defining a concurrent program begins by
defining the basic building block of a
program which will be called an Activities.
ASYNCHRONOUS ACTIVITIES
 An activities could be formally defined as
anything that could be done by abstract
Turing machine or as an algorithm.
ASYNCHRONOUS ACTIVITIES
 Like a working definition , it is sufficient to
define an activity as simply a series of steps
implemented to perform a task.
 Baking a pie or calculating a Fibonacci
number on a computer.
ASYNCHRONOUS ACTIVITIES
 The steps required to perform a task will be
called an ordering.
ASYNCHRONOUS ACTIVITIES
 Activities can be broken down into
subactivities, each an activity itself.
 Baking a pie could consist of making the
crust, making the filling,filling the crust with
the filling, and baking the pie.
Make Crust Make Filling Add Filling Bake a Pie
ASYNCHRONOUS ACTIVITIES
 If the order of these activities is completely fixed,
then the ordering is called a total ordering, as
all steps in all activities are ordered.
 In the case of a total orderings of events, the
next step to be taken can always be determined
by the activiity.
ASYNCHRONOUS ACTIVITIES
 An activities for which the order of the
steps is determined by activity is called a
synchronous activity.
 If the order can be changed, then the
ordering is called partial ordering.
ASYNCHRONOUS ACTIVITIES
 If one activity must always finish before the
another begins, it posible to implement this
behavior with a synchronous activity.
 A special case occurs when, for a partial
ordering, the next step is not determined by a
single activity.
ASYNCHRONOUS ACTIVITIES
t1c
t1f
Make Filling
Make a Crust
t2c
t2f
Add Filling Bake Pie
ASYNCHRONOUS ACTIVITIES
 The activity where the steps involved in
the two substaks are being executed
independently, or asynchronously, of each
other is called asynchronous activity.
ASYNCHRONOUS ACTIVITIES
 The definition of an asynchronous activity
leads to a very simple definition of
concurrency:
 Concurrency is defined as the presence of
two or more asynchronous activities.
ASYNCHRONOUS ACTIVITIES
 When asynchronous activities are present
in a program, it is possible (but not
necesary) for the steps for the two
activities to interleave.
ASYNCHRONOUS ACTIVITIES
 From the definition of asynchronous
activities the two activities do not have to
run at the same time; they simple have to
be able to run at the same time.
ASYNCHRONOUS ACTIVITIES
 The problems that will be encountered in
concurrency occur not because the
activities execute at the same time but
because they can interleave their
executions.
ASYNCHRONOUS ACTIVITIES
 If a program allows activities to
interleave, it must protect against the ill
effects of that interleaving whether it
occurs or not.
ASYNCHRONOUS ACTIVITIES
 The importance of the improvement of
this definition of concurrency over the
definition of concurrency as a multiple
activities happening at the same time
cannot be overemphasized.
ASYNCHRONOUS ACTIVITIES
 If a concurrent program does not actually
run two activities at the same time, but it
can do so, then action must be taken to
make sure problems do not occur.
ASYNCHRONOUS ACTIVITIES
 Two threads running in a program are
asynchronous activities,thus they are
concurrent.
ASYNCHRONOUS ACTIVITIES
 Two computers running in different cities
are also asynchronous activities, so the
definition of concurrent must be further
tightened.
SYNCHRONIZATION OF ASYNCHRONOUS ACTIVITIES
 That two or more asynchronous activities
are concurrent is good definition of
concurrency, but it is not useful definition.
SYNCHRONIZATION OF ASYNCHRONOUS ACTIVITIES
 Sebesta R. say that, “Synchronization is
a mechanism that controls the order in
which tasks execute”.
Concepts of Programming Languages
,Addison-Wesley, Reading MA.1999
COMPETITIVE AND COOPERATIVE SYNCHRONIZATION
 Sebesta R. , define two types of
synchronization:
SYNCHRONIZATION OF ASYNCHRONOUS ACTIVITIES
 Sebesta R. , define two types of
synchronization:
Competitives synchronization
Cooperative synchronization
COMPETITIVE AND COOPERATIVE SYNCHRONIZATION
Make Filling
Make a Crust
Cooperative
Synchronization
Add Filling Bake PieMixing
Bold
Competitive
Synchronizaation
CONCURRENT PROGRAMMING
 Concurrent Program: A program that
contains asynchronous activities which
synchronize at one or more points or on one
or more resources during execution.
COMPONENTS
 An interesting way to look at a
concurrent program is to think of it
as containing two types of units,
activities that act on other entities or
entities that control the interactions
of these activities.
COMPONENTS
 If this units are objects, then in a
concurrent program all objects in the
program can be made to be either active
(asynchronous activities such as threads)
or pasive ( such as a shared resource or
an event that is used for synchronization).
COMPONENTS
 Other types of simple, non-
concurrennt objects are used by
active and passive objects, such as
Vector or StringTokenizers, but these
are not involved in the concurrency in
the program.
COMPONENTS
 Passive objects, which from
now on will be called
concurrent component or
simple components,are more
difficult for most students.
COMPONENTS
 This is likely because they
provide the infraestructure for
the asynchronous activities that
executed in a concurrent
program.
COMPONENTS
 Components in the example of
making a pie are the shared
mixing bowl and the event that
significates that the preparation
of the crust and filling is
completed.
COMPONENTS
 The components control the
behavior of the asynchronous
activities so that they
coordinate and produce a
correct result.
COMPONENTS
 The components sit between asynchronous
activities and are shared and used by
multiple asynchronous activities.
COMPONENTS
 Note that not all objects that are non-active
are components.
 A vector is safe to use in a multi-threaded
program, but it is not component because
even if it is used by a number of threads it is
not normally used to coordinate between
those threads.
COMPONENTS
 Objects are added or removed from vector,
but the vector is used just to store data
elements, not to coordinate the
asynchronous activities.
COMPONENTS
 A special type of vector called bounded
buffer is actually used to coordinate
between asynchronous activities.
COMPONENTS
 Because components provide an
infraestructur for asynchronous activities and
coordinate between these activities, they
have a number of characteristics that must
be considered that do not exist when
implementing normal object.
SOME CHARACTERISTICS OF COMPONENTS
 Because components coordinate between
several threads, they can not be created or
owned by a single thread; therefore, some
mechanism must be used to allow these
objects to be registered, or to register
themselves, with other objects representing
the asynchronous activities.
SOME CHARACTERISTICS OF COMPONENTS
 Because components are used in separate
asynchronous activities and, in the extreme
case of distributing computing, on physically
different computers, some mechanism must
be implemented to allows the components
to communicate with asynchronous activities.
SOME CHARACTERISTICS OF COMPONENTS
 Unlike objects for asynchronous activities,
which can be designed using procedural
flow, the logic in a component is generally
organized around the state of the
component when it is executed. Some
mechanism needs to be designed to
effectively implement the components to
allow them to provide this coordination.
SOME CHARACTERISTICS OF COMPONENTS
 Some harmfull interactions, called race
conditions, can occur if the object are not
properly designed. One way to avoid race
conditions is to make all the methods in the
object synchronized and not allow an object
to give up the object’s lock while executing.
SOME CHARACTERISTICS OF COMPONENTS
This is called complete synchronization
and is sufficient for non component
objects such as String or a Vector;
however, components must coordinate
between several objects, and complete
synchronization is too restrictive to
effectively implement this coordination.
SOME CHARACTERISTICS OF COMPONENTS
 A second type of harmful interaction, called a
deadlock, can result if the component is not
properly designed. Deadlock can occur in
any concurrent program when objects are
improperly handled; however, the posibility
of deadlock can actually be built into
components that are not designed properly,
even if the component is used correctly.

More Related Content

Similar to Concurrent programing

Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering
Madhar Khan Pathan
 
Async.pdf
Async.pdfAsync.pdf
Synchronous vs Asynchronous Programming
Synchronous vs Asynchronous ProgrammingSynchronous vs Asynchronous Programming
Synchronous vs Asynchronous Programming
jeetendra mandal
 
Open modeling and simulation framework for evolutive analysis
Open modeling and simulation framework for evolutive analysisOpen modeling and simulation framework for evolutive analysis
Open modeling and simulation framework for evolutive analysis
Servicio de Difusión de la Creación Intelectual (SEDICI)
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
MugiiiReee
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
Gabor Varadi
 
Solid Principles I: The Secret of Life
Solid Principles I: The Secret of LifeSolid Principles I: The Secret of Life
Solid Principles I: The Secret of Life
Kristjan Siimson
 
Activities vs fragment
Activities vs fragmentActivities vs fragment
Activities vs fragment
Inova LLC
 
Lab3-Android
Lab3-AndroidLab3-Android
Lab3-Android
Lilia Sfaxi
 
A Recent Encounter
A Recent EncounterA Recent Encounter
A Recent Encounter
Glen Alleman
 
Component based models and technology
Component based models and technologyComponent based models and technology
Component based models and technologySaransh Garg
 
Overview Sphere M&E system
Overview Sphere M&E systemOverview Sphere M&E system
Overview Sphere M&E system
sphereworld
 
Content-Driven Apps with React
Content-Driven Apps with ReactContent-Driven Apps with React
Content-Driven Apps with React
Netcetera
 
Lec2.pptx
Lec2.pptxLec2.pptx
Component based models and technology
Component based models and technologyComponent based models and technology
Component based models and technology
Mayukh Maitra
 
07 software design
07   software design07   software design
07 software designkebsterz
 
07 software design
07   software design07   software design
07 software designkebsterz
 
GUI Programming in JAVA (Using Netbeans) - A Review
GUI Programming in JAVA (Using Netbeans) -  A ReviewGUI Programming in JAVA (Using Netbeans) -  A Review
GUI Programming in JAVA (Using Netbeans) - A Review
Fernando Torres
 

Similar to Concurrent programing (20)

Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering
 
Async.pdf
Async.pdfAsync.pdf
Async.pdf
 
Synchronous vs Asynchronous Programming
Synchronous vs Asynchronous ProgrammingSynchronous vs Asynchronous Programming
Synchronous vs Asynchronous Programming
 
Multi projects
Multi projectsMulti projects
Multi projects
 
Open modeling and simulation framework for evolutive analysis
Open modeling and simulation framework for evolutive analysisOpen modeling and simulation framework for evolutive analysis
Open modeling and simulation framework for evolutive analysis
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
 
Solid Principles I: The Secret of Life
Solid Principles I: The Secret of LifeSolid Principles I: The Secret of Life
Solid Principles I: The Secret of Life
 
Activities vs fragment
Activities vs fragmentActivities vs fragment
Activities vs fragment
 
Lab3-Android
Lab3-AndroidLab3-Android
Lab3-Android
 
A Recent Encounter
A Recent EncounterA Recent Encounter
A Recent Encounter
 
Component based models and technology
Component based models and technologyComponent based models and technology
Component based models and technology
 
Overview Sphere M&E system
Overview Sphere M&E systemOverview Sphere M&E system
Overview Sphere M&E system
 
Uml examples
Uml examplesUml examples
Uml examples
 
Content-Driven Apps with React
Content-Driven Apps with ReactContent-Driven Apps with React
Content-Driven Apps with React
 
Lec2.pptx
Lec2.pptxLec2.pptx
Lec2.pptx
 
Component based models and technology
Component based models and technologyComponent based models and technology
Component based models and technology
 
07 software design
07   software design07   software design
07 software design
 
07 software design
07   software design07   software design
07 software design
 
GUI Programming in JAVA (Using Netbeans) - A Review
GUI Programming in JAVA (Using Netbeans) -  A ReviewGUI Programming in JAVA (Using Netbeans) -  A Review
GUI Programming in JAVA (Using Netbeans) - A Review
 

More from Alvaro Pino

Module 01a2020
Module 01a2020Module 01a2020
Module 01a2020
Alvaro Pino
 
Module 01a2020
Module 01a2020Module 01a2020
Module 01a2020
Alvaro Pino
 
Regla derecha izquierda
Regla derecha   izquierdaRegla derecha   izquierda
Regla derecha izquierda
Alvaro Pino
 
Chap 15gpin
Chap 15gpinChap 15gpin
Chap 15gpin
Alvaro Pino
 
Chap 15fpin
Chap 15fpinChap 15fpin
Chap 15fpin
Alvaro Pino
 
Chap 15epin
Chap 15epinChap 15epin
Chap 15epin
Alvaro Pino
 
Chap 15dpin
Chap 15dpinChap 15dpin
Chap 15dpin
Alvaro Pino
 
Chap 15cpin
Chap 15cpinChap 15cpin
Chap 15cpin
Alvaro Pino
 
Chap 15bpin
Chap 15bpinChap 15bpin
Chap 15bpin
Alvaro Pino
 
Chap 15apin
Chap 15apinChap 15apin
Chap 15apin
Alvaro Pino
 

More from Alvaro Pino (10)

Module 01a2020
Module 01a2020Module 01a2020
Module 01a2020
 
Module 01a2020
Module 01a2020Module 01a2020
Module 01a2020
 
Regla derecha izquierda
Regla derecha   izquierdaRegla derecha   izquierda
Regla derecha izquierda
 
Chap 15gpin
Chap 15gpinChap 15gpin
Chap 15gpin
 
Chap 15fpin
Chap 15fpinChap 15fpin
Chap 15fpin
 
Chap 15epin
Chap 15epinChap 15epin
Chap 15epin
 
Chap 15dpin
Chap 15dpinChap 15dpin
Chap 15dpin
 
Chap 15cpin
Chap 15cpinChap 15cpin
Chap 15cpin
 
Chap 15bpin
Chap 15bpinChap 15bpin
Chap 15bpin
 
Chap 15apin
Chap 15apinChap 15apin
Chap 15apin
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 

Concurrent programing

  • 2. CHAPTER GOALS  Understand why concurrent programming is important.  Give a working definition of concurrent program.  Understand the two types of synchronization and give examples of each.
  • 3. CHAPTER GOALS  Give a definition of the term component and know what special problems can be encountered when using components.  Describe several different reasons for doing concurrent programming and how each of these reasons leads to different design decisions and different program implementation.
  • 4. WHAT IS CONCURRENT PROGRAMMING ?  The purpose of this course is to help the students understand how to create concurrent programs with special concurrent object, called concurrent components.  This components are used only in concurrent programs.
  • 5. WHAT IS CONCURRENT PROGRAMMING ?  A good definition of a concurrent program is needed before components can be defined and methods given for their implementation.  This chapter provides a good working definition of a concurrent program after explaining why concurrent programming is important concept for programmer to know.
  • 6. WHAT IS CONCURRENT PROGRAMMING ?  The working definition of a concurrent program provided here will serve as a basis for understand concurrent programming throughout the course.
  • 7. WHAT IS CONCURRENT PROGRAMMING ?  The definition of an asynchronous activity leads to very simple definition of concurrency: Concurrency is defined as the presence of two or more asynchronous activities.
  • 8. ASYNCHRONOUS ACTIVITIES  Defining a concurrent program begins by defining the basic building block of a program which will be called an Activities.
  • 9. ASYNCHRONOUS ACTIVITIES  An activities could be formally defined as anything that could be done by abstract Turing machine or as an algorithm.
  • 10. ASYNCHRONOUS ACTIVITIES  Like a working definition , it is sufficient to define an activity as simply a series of steps implemented to perform a task.  Baking a pie or calculating a Fibonacci number on a computer.
  • 11. ASYNCHRONOUS ACTIVITIES  The steps required to perform a task will be called an ordering.
  • 12. ASYNCHRONOUS ACTIVITIES  Activities can be broken down into subactivities, each an activity itself.  Baking a pie could consist of making the crust, making the filling,filling the crust with the filling, and baking the pie. Make Crust Make Filling Add Filling Bake a Pie
  • 13. ASYNCHRONOUS ACTIVITIES  If the order of these activities is completely fixed, then the ordering is called a total ordering, as all steps in all activities are ordered.  In the case of a total orderings of events, the next step to be taken can always be determined by the activiity.
  • 14. ASYNCHRONOUS ACTIVITIES  An activities for which the order of the steps is determined by activity is called a synchronous activity.  If the order can be changed, then the ordering is called partial ordering.
  • 15. ASYNCHRONOUS ACTIVITIES  If one activity must always finish before the another begins, it posible to implement this behavior with a synchronous activity.  A special case occurs when, for a partial ordering, the next step is not determined by a single activity.
  • 16. ASYNCHRONOUS ACTIVITIES t1c t1f Make Filling Make a Crust t2c t2f Add Filling Bake Pie
  • 17. ASYNCHRONOUS ACTIVITIES  The activity where the steps involved in the two substaks are being executed independently, or asynchronously, of each other is called asynchronous activity.
  • 18. ASYNCHRONOUS ACTIVITIES  The definition of an asynchronous activity leads to a very simple definition of concurrency:  Concurrency is defined as the presence of two or more asynchronous activities.
  • 19. ASYNCHRONOUS ACTIVITIES  When asynchronous activities are present in a program, it is possible (but not necesary) for the steps for the two activities to interleave.
  • 20. ASYNCHRONOUS ACTIVITIES  From the definition of asynchronous activities the two activities do not have to run at the same time; they simple have to be able to run at the same time.
  • 21. ASYNCHRONOUS ACTIVITIES  The problems that will be encountered in concurrency occur not because the activities execute at the same time but because they can interleave their executions.
  • 22. ASYNCHRONOUS ACTIVITIES  If a program allows activities to interleave, it must protect against the ill effects of that interleaving whether it occurs or not.
  • 23. ASYNCHRONOUS ACTIVITIES  The importance of the improvement of this definition of concurrency over the definition of concurrency as a multiple activities happening at the same time cannot be overemphasized.
  • 24. ASYNCHRONOUS ACTIVITIES  If a concurrent program does not actually run two activities at the same time, but it can do so, then action must be taken to make sure problems do not occur.
  • 25. ASYNCHRONOUS ACTIVITIES  Two threads running in a program are asynchronous activities,thus they are concurrent.
  • 26. ASYNCHRONOUS ACTIVITIES  Two computers running in different cities are also asynchronous activities, so the definition of concurrent must be further tightened.
  • 27. SYNCHRONIZATION OF ASYNCHRONOUS ACTIVITIES  That two or more asynchronous activities are concurrent is good definition of concurrency, but it is not useful definition.
  • 28. SYNCHRONIZATION OF ASYNCHRONOUS ACTIVITIES  Sebesta R. say that, “Synchronization is a mechanism that controls the order in which tasks execute”. Concepts of Programming Languages ,Addison-Wesley, Reading MA.1999
  • 29. COMPETITIVE AND COOPERATIVE SYNCHRONIZATION  Sebesta R. , define two types of synchronization:
  • 30. SYNCHRONIZATION OF ASYNCHRONOUS ACTIVITIES  Sebesta R. , define two types of synchronization: Competitives synchronization Cooperative synchronization
  • 31. COMPETITIVE AND COOPERATIVE SYNCHRONIZATION Make Filling Make a Crust Cooperative Synchronization Add Filling Bake PieMixing Bold Competitive Synchronizaation
  • 32. CONCURRENT PROGRAMMING  Concurrent Program: A program that contains asynchronous activities which synchronize at one or more points or on one or more resources during execution.
  • 33. COMPONENTS  An interesting way to look at a concurrent program is to think of it as containing two types of units, activities that act on other entities or entities that control the interactions of these activities.
  • 34. COMPONENTS  If this units are objects, then in a concurrent program all objects in the program can be made to be either active (asynchronous activities such as threads) or pasive ( such as a shared resource or an event that is used for synchronization).
  • 35. COMPONENTS  Other types of simple, non- concurrennt objects are used by active and passive objects, such as Vector or StringTokenizers, but these are not involved in the concurrency in the program.
  • 36. COMPONENTS  Passive objects, which from now on will be called concurrent component or simple components,are more difficult for most students.
  • 37. COMPONENTS  This is likely because they provide the infraestructure for the asynchronous activities that executed in a concurrent program.
  • 38. COMPONENTS  Components in the example of making a pie are the shared mixing bowl and the event that significates that the preparation of the crust and filling is completed.
  • 39. COMPONENTS  The components control the behavior of the asynchronous activities so that they coordinate and produce a correct result.
  • 40. COMPONENTS  The components sit between asynchronous activities and are shared and used by multiple asynchronous activities.
  • 41. COMPONENTS  Note that not all objects that are non-active are components.  A vector is safe to use in a multi-threaded program, but it is not component because even if it is used by a number of threads it is not normally used to coordinate between those threads.
  • 42. COMPONENTS  Objects are added or removed from vector, but the vector is used just to store data elements, not to coordinate the asynchronous activities.
  • 43. COMPONENTS  A special type of vector called bounded buffer is actually used to coordinate between asynchronous activities.
  • 44. COMPONENTS  Because components provide an infraestructur for asynchronous activities and coordinate between these activities, they have a number of characteristics that must be considered that do not exist when implementing normal object.
  • 45. SOME CHARACTERISTICS OF COMPONENTS  Because components coordinate between several threads, they can not be created or owned by a single thread; therefore, some mechanism must be used to allow these objects to be registered, or to register themselves, with other objects representing the asynchronous activities.
  • 46. SOME CHARACTERISTICS OF COMPONENTS  Because components are used in separate asynchronous activities and, in the extreme case of distributing computing, on physically different computers, some mechanism must be implemented to allows the components to communicate with asynchronous activities.
  • 47. SOME CHARACTERISTICS OF COMPONENTS  Unlike objects for asynchronous activities, which can be designed using procedural flow, the logic in a component is generally organized around the state of the component when it is executed. Some mechanism needs to be designed to effectively implement the components to allow them to provide this coordination.
  • 48. SOME CHARACTERISTICS OF COMPONENTS  Some harmfull interactions, called race conditions, can occur if the object are not properly designed. One way to avoid race conditions is to make all the methods in the object synchronized and not allow an object to give up the object’s lock while executing.
  • 49. SOME CHARACTERISTICS OF COMPONENTS This is called complete synchronization and is sufficient for non component objects such as String or a Vector; however, components must coordinate between several objects, and complete synchronization is too restrictive to effectively implement this coordination.
  • 50. SOME CHARACTERISTICS OF COMPONENTS  A second type of harmful interaction, called a deadlock, can result if the component is not properly designed. Deadlock can occur in any concurrent program when objects are improperly handled; however, the posibility of deadlock can actually be built into components that are not designed properly, even if the component is used correctly.