SlideShare uma empresa Scribd logo
1 de 4
ICS 313 - Fundamentals of Programming Languages 1
13. Concurrency
13.1 Introduction
Concurrency can occur at four levels:
1. Machine instruction level
2. High-level language statement level
3. Unit level
4. Program level
Because there are no language issues in instruction and program-level
concurrency, they are not addressed here
The Evolution of Multiprocessor Architectures
Late 1950s - One general-purpose processor and one or more special-
purpose processors for input and output operations
Early 1960s - Multiple complete processors, used for program-level
concurrency
Mid-1960s - Multiple partial processors, used for instruction-level
concurrency
Single-Instruction Multiple-Data (SIMD) machines. The same instruction
goes to all processors, each with different data - e.g., vector processors
Multiple-Instruction Multiple-Data (MIMD) machines - Independent processors that
can be synchronized (unit-level concurrency)
ICS 313 - Fundamentals of Programming Languages 2
13.1 Introduction (continued)
A thread of control in a program is the sequence of program points
reached as control flows through the program
Categories of Concurrency
Physical concurrency - Multiple independent processors
(multiple threads of control)
Logical concurrency - The appearance of physical concurrency is
presented by time-sharing one processor
(software can be designed as if there were multiple threads of control)
Coroutines provide only quasi-concurrency
Reasons to Study Concurrency
It involves a different way of designing software that can be very useful
- many real-world situations involve concurrency
Computers capable of physical concurrency are now widely used
13.2 Intro to Subprogram-Level Concurrency
A task is a program unit that can be in concurrent execution with other
program units
Tasks differ from ordinary subprograms in that:
A task may be implicitly started
When a program unit starts the execution of a task, it is not necessarily
suspended
When a task’s execution is completed, control may not return to the caller
Tasks usually work together
A task is disjoint if it does not communicate with or affect the execution
of any other task in the program in any way
Task communication is necessary for synchronization
Task communication can be through:
Shared nonlocal variables
Parameters
Message passing
ICS 313 - Fundamentals of Programming Languages 3
13.2 Intro to Subprogram-Level Concurrency (continued)
Kinds of synchronization
Cooperation
Task A must wait for task B to complete some specific activity before task A can continue its execution e.g., the
producer-consumer problem
Competition
When two or more tasks must use some resource that cannot be simultaneously used e.g., a shared counter
Competition is usually provided by mutually exclusive access
Providing synchronization requires a mechanism for delaying task execution
Task execution control is maintained by a program called the scheduler, which
maps task execution onto available processors
Tasks can be in one of several different execution states:
New - created but not yet started
Runnable or ready - ready to run but not currently running (no available processor)
Running
Blocked - has been running, but cannot now continue (usually waiting for some
event to occur)
Dead - no longer active in any sense
13.2 Intro to Subprogram-Level Concurrency (continued)
Liveness is a characteristic that a program unit may or may not have
In sequential code, it means the unit will eventually complete its execution
In a concurrent environment, a task can easily lose its liveness
If all tasks in a concurrent environment lose their liveness, it is called
deadlock
Design Issues for Concurrency
How is cooperation synchronization provided?
How is competition synchronization provided?
How and when do tasks begin and end execution?
Are tasks statically or dynamically created?
Methods of Providing Synchronization:
Semaphores
Monitors
Message Passing
ICS 313 - Fundamentals of Programming Languages 4
13.7 Java Threads
The concurrent units in Java are run methods
The run method is inherited and overriden in subclasses of
the predefined Thread class
The Thread Class
Includes several methods (besides run)
start, which calls run , after which control returns immediately to
start
yield, which stops execution of the thread and puts it in the task
ready queue
sleep, which stops execution of the thread and blocks it from
execution for the amount of time specified in its parameter
Early versions of Java used three more Thread methods
suspend, which stops execution of the thread until it is restarted with resume
resume, which restarts a suspended thread
stop, which kills the thread
13.7 Java Threads (continued)
Competition Synchronization with Java Threads
A method that includes the synchronized modifier disallows any
other method from running on the object while it is in execution
If only a part of a method must be run without interference, it can be
synchronized
Cooperation Synchronization with Java Threads
The wait and notify methods are defined in Object, which is the root
class in Java, so all objects inherit them
The wait method must be called in a loop
Example - the queue
See Queue class (pp. 549-550) and the Producer and Consumer
classes (p. 550)

Mais conteúdo relacionado

Mais procurados

client-server-computing.pdf
client-server-computing.pdfclient-server-computing.pdf
client-server-computing.pdfscribdrg
 
project management in it context
 project management in it context project management in it context
project management in it contextSidraSaleem17
 
parallel language and compiler
parallel language and compilerparallel language and compiler
parallel language and compilerVignesh Tamil
 
Software Test Metrics and Measurements
Software Test Metrics and MeasurementsSoftware Test Metrics and Measurements
Software Test Metrics and MeasurementsDavis Thomas
 
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...10-Software Project Management (Object Oriented Software Engineering - BNU Sp...
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...Hafiz Ammar Siddiqui
 
Software engineering mca
Software engineering mcaSoftware engineering mca
Software engineering mcaAman Adhikari
 
MonkeyTalk Automation Testing For Android Application
MonkeyTalk Automation Testing For Android ApplicationMonkeyTalk Automation Testing For Android Application
MonkeyTalk Automation Testing For Android ApplicationContusQA
 
Synchronization in distributed systems
Synchronization in distributed systems Synchronization in distributed systems
Synchronization in distributed systems SHATHAN
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS BasicsShijin Raj P
 
White Box Testing And Control Flow & Loop Testing
White Box Testing And Control Flow & Loop TestingWhite Box Testing And Control Flow & Loop Testing
White Box Testing And Control Flow & Loop TestingAnkit Mulani
 
How to take organizations to higher testing maturity suresh bose anagha mahaj...
How to take organizations to higher testing maturity suresh bose anagha mahaj...How to take organizations to higher testing maturity suresh bose anagha mahaj...
How to take organizations to higher testing maturity suresh bose anagha mahaj...Anagha Mahajan
 
Comparing Software Quality Assurance Techniques And Activities
Comparing Software Quality Assurance Techniques And ActivitiesComparing Software Quality Assurance Techniques And Activities
Comparing Software Quality Assurance Techniques And ActivitiesLemia Algmri
 
IT8076 - SOFTWARE TESTING
IT8076 - SOFTWARE TESTINGIT8076 - SOFTWARE TESTING
IT8076 - SOFTWARE TESTINGSathya R
 
Distributed system notes unit I
Distributed system notes unit IDistributed system notes unit I
Distributed system notes unit INANDINI SHARMA
 
Remote network monitoring
Remote network monitoringRemote network monitoring
Remote network monitoringyousef emami
 
Software Development Software development process
Software Development Software development processSoftware Development Software development process
Software Development Software development processimtiazalijoono
 

Mais procurados (20)

client-server-computing.pdf
client-server-computing.pdfclient-server-computing.pdf
client-server-computing.pdf
 
project management in it context
 project management in it context project management in it context
project management in it context
 
parallel language and compiler
parallel language and compilerparallel language and compiler
parallel language and compiler
 
Software Test Metrics and Measurements
Software Test Metrics and MeasurementsSoftware Test Metrics and Measurements
Software Test Metrics and Measurements
 
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...10-Software Project Management (Object Oriented Software Engineering - BNU Sp...
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...
 
Sdlc
SdlcSdlc
Sdlc
 
Software engineering mca
Software engineering mcaSoftware engineering mca
Software engineering mca
 
MonkeyTalk Automation Testing For Android Application
MonkeyTalk Automation Testing For Android ApplicationMonkeyTalk Automation Testing For Android Application
MonkeyTalk Automation Testing For Android Application
 
Cloud sim report
Cloud sim reportCloud sim report
Cloud sim report
 
Testing Metrics
Testing MetricsTesting Metrics
Testing Metrics
 
Synchronization in distributed systems
Synchronization in distributed systems Synchronization in distributed systems
Synchronization in distributed systems
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS Basics
 
White Box Testing And Control Flow & Loop Testing
White Box Testing And Control Flow & Loop TestingWhite Box Testing And Control Flow & Loop Testing
White Box Testing And Control Flow & Loop Testing
 
CS6601 DISTRIBUTED SYSTEMS
CS6601 DISTRIBUTED SYSTEMSCS6601 DISTRIBUTED SYSTEMS
CS6601 DISTRIBUTED SYSTEMS
 
How to take organizations to higher testing maturity suresh bose anagha mahaj...
How to take organizations to higher testing maturity suresh bose anagha mahaj...How to take organizations to higher testing maturity suresh bose anagha mahaj...
How to take organizations to higher testing maturity suresh bose anagha mahaj...
 
Comparing Software Quality Assurance Techniques And Activities
Comparing Software Quality Assurance Techniques And ActivitiesComparing Software Quality Assurance Techniques And Activities
Comparing Software Quality Assurance Techniques And Activities
 
IT8076 - SOFTWARE TESTING
IT8076 - SOFTWARE TESTINGIT8076 - SOFTWARE TESTING
IT8076 - SOFTWARE TESTING
 
Distributed system notes unit I
Distributed system notes unit IDistributed system notes unit I
Distributed system notes unit I
 
Remote network monitoring
Remote network monitoringRemote network monitoring
Remote network monitoring
 
Software Development Software development process
Software Development Software development processSoftware Development Software development process
Software Development Software development process
 

Semelhante a 13 concurrency

operating system for computer engineering ch3.ppt
operating system for computer engineering ch3.pptoperating system for computer engineering ch3.ppt
operating system for computer engineering ch3.pptgezaegebre1
 
ch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included picturesch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included picturesPranjalRana4
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSKathirvel Ayyaswamy
 
Process Management Operating Systems .pptx
Process Management        Operating Systems .pptxProcess Management        Operating Systems .pptx
Process Management Operating Systems .pptxSAIKRISHNADURVASULA2
 
distributed-systemsfghjjjijoijioj-chap3.pptx
distributed-systemsfghjjjijoijioj-chap3.pptxdistributed-systemsfghjjjijoijioj-chap3.pptx
distributed-systemsfghjjjijoijioj-chap3.pptxlencho3d
 
parallel programming models
 parallel programming models parallel programming models
parallel programming modelsSwetha S
 
Mulitthread
MulitthreadMulitthread
MulitthreadDeepaR42
 
Multi t hreading_14_10
Multi t hreading_14_10Multi t hreading_14_10
Multi t hreading_14_10Minal Maniar
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving TechniquesAshesh R
 
Task communication
Task communicationTask communication
Task communication1jayanti
 
Operating system concepts ninth edition (2012), chapter 2 solution e1
Operating system concepts ninth edition (2012), chapter 2 solution e1Operating system concepts ninth edition (2012), chapter 2 solution e1
Operating system concepts ninth edition (2012), chapter 2 solution e1Navid Daneshvaran
 
Parallel Processing (Part 2)
Parallel Processing (Part 2)Parallel Processing (Part 2)
Parallel Processing (Part 2)Ajeng Savitri
 

Semelhante a 13 concurrency (20)

Java multi thread programming on cmp system
Java multi thread programming on cmp systemJava multi thread programming on cmp system
Java multi thread programming on cmp system
 
Chapter05 new
Chapter05 newChapter05 new
Chapter05 new
 
operating system for computer engineering ch3.ppt
operating system for computer engineering ch3.pptoperating system for computer engineering ch3.ppt
operating system for computer engineering ch3.ppt
 
ch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included picturesch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included pictures
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
 
Process Management Operating Systems .pptx
Process Management        Operating Systems .pptxProcess Management        Operating Systems .pptx
Process Management Operating Systems .pptx
 
Concurrency in c#
Concurrency in c#Concurrency in c#
Concurrency in c#
 
Interactive debugging system
Interactive debugging systemInteractive debugging system
Interactive debugging system
 
Chapter 3 chapter reading task
Chapter 3 chapter reading taskChapter 3 chapter reading task
Chapter 3 chapter reading task
 
Threads
ThreadsThreads
Threads
 
Spr ch-01
Spr ch-01Spr ch-01
Spr ch-01
 
distributed-systemsfghjjjijoijioj-chap3.pptx
distributed-systemsfghjjjijoijioj-chap3.pptxdistributed-systemsfghjjjijoijioj-chap3.pptx
distributed-systemsfghjjjijoijioj-chap3.pptx
 
parallel programming models
 parallel programming models parallel programming models
parallel programming models
 
UNIT 2 ECSE-2.pptx
UNIT 2 ECSE-2.pptxUNIT 2 ECSE-2.pptx
UNIT 2 ECSE-2.pptx
 
Mulitthread
MulitthreadMulitthread
Mulitthread
 
Multi t hreading_14_10
Multi t hreading_14_10Multi t hreading_14_10
Multi t hreading_14_10
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
Task communication
Task communicationTask communication
Task communication
 
Operating system concepts ninth edition (2012), chapter 2 solution e1
Operating system concepts ninth edition (2012), chapter 2 solution e1Operating system concepts ninth edition (2012), chapter 2 solution e1
Operating system concepts ninth edition (2012), chapter 2 solution e1
 
Parallel Processing (Part 2)
Parallel Processing (Part 2)Parallel Processing (Part 2)
Parallel Processing (Part 2)
 

Mais de jigeno

Access2007 part1
Access2007 part1Access2007 part1
Access2007 part1jigeno
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms accessjigeno
 
16 logical programming
16 logical programming16 logical programming
16 logical programmingjigeno
 
15 functional programming
15 functional programming15 functional programming
15 functional programmingjigeno
 
15 functional programming
15 functional programming15 functional programming
15 functional programmingjigeno
 
14 exception handling
14 exception handling14 exception handling
14 exception handlingjigeno
 
12 object oriented programming
12 object oriented programming12 object oriented programming
12 object oriented programmingjigeno
 
11 abstract data types
11 abstract data types11 abstract data types
11 abstract data typesjigeno
 
9 subprograms
9 subprograms9 subprograms
9 subprogramsjigeno
 
8 statement-level control structure
8 statement-level control structure8 statement-level control structure
8 statement-level control structurejigeno
 
7 expressions and assignment statements
7 expressions and assignment statements7 expressions and assignment statements
7 expressions and assignment statementsjigeno
 
6 data types
6 data types6 data types
6 data typesjigeno
 
5 names
5 names5 names
5 namesjigeno
 
4 lexical and syntax analysis
4 lexical and syntax analysis4 lexical and syntax analysis
4 lexical and syntax analysisjigeno
 
3 describing syntax and semantics
3 describing syntax and semantics3 describing syntax and semantics
3 describing syntax and semanticsjigeno
 
2 evolution of the major programming languages
2 evolution of the major programming languages2 evolution of the major programming languages
2 evolution of the major programming languagesjigeno
 
1 preliminaries
1 preliminaries1 preliminaries
1 preliminariesjigeno
 
Access2007 m2
Access2007 m2Access2007 m2
Access2007 m2jigeno
 
Access2007 m1
Access2007 m1Access2007 m1
Access2007 m1jigeno
 

Mais de jigeno (20)

Access2007 part1
Access2007 part1Access2007 part1
Access2007 part1
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms access
 
Bsit1
Bsit1Bsit1
Bsit1
 
16 logical programming
16 logical programming16 logical programming
16 logical programming
 
15 functional programming
15 functional programming15 functional programming
15 functional programming
 
15 functional programming
15 functional programming15 functional programming
15 functional programming
 
14 exception handling
14 exception handling14 exception handling
14 exception handling
 
12 object oriented programming
12 object oriented programming12 object oriented programming
12 object oriented programming
 
11 abstract data types
11 abstract data types11 abstract data types
11 abstract data types
 
9 subprograms
9 subprograms9 subprograms
9 subprograms
 
8 statement-level control structure
8 statement-level control structure8 statement-level control structure
8 statement-level control structure
 
7 expressions and assignment statements
7 expressions and assignment statements7 expressions and assignment statements
7 expressions and assignment statements
 
6 data types
6 data types6 data types
6 data types
 
5 names
5 names5 names
5 names
 
4 lexical and syntax analysis
4 lexical and syntax analysis4 lexical and syntax analysis
4 lexical and syntax analysis
 
3 describing syntax and semantics
3 describing syntax and semantics3 describing syntax and semantics
3 describing syntax and semantics
 
2 evolution of the major programming languages
2 evolution of the major programming languages2 evolution of the major programming languages
2 evolution of the major programming languages
 
1 preliminaries
1 preliminaries1 preliminaries
1 preliminaries
 
Access2007 m2
Access2007 m2Access2007 m2
Access2007 m2
 
Access2007 m1
Access2007 m1Access2007 m1
Access2007 m1
 

Último

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Último (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

13 concurrency

  • 1. ICS 313 - Fundamentals of Programming Languages 1 13. Concurrency 13.1 Introduction Concurrency can occur at four levels: 1. Machine instruction level 2. High-level language statement level 3. Unit level 4. Program level Because there are no language issues in instruction and program-level concurrency, they are not addressed here The Evolution of Multiprocessor Architectures Late 1950s - One general-purpose processor and one or more special- purpose processors for input and output operations Early 1960s - Multiple complete processors, used for program-level concurrency Mid-1960s - Multiple partial processors, used for instruction-level concurrency Single-Instruction Multiple-Data (SIMD) machines. The same instruction goes to all processors, each with different data - e.g., vector processors Multiple-Instruction Multiple-Data (MIMD) machines - Independent processors that can be synchronized (unit-level concurrency)
  • 2. ICS 313 - Fundamentals of Programming Languages 2 13.1 Introduction (continued) A thread of control in a program is the sequence of program points reached as control flows through the program Categories of Concurrency Physical concurrency - Multiple independent processors (multiple threads of control) Logical concurrency - The appearance of physical concurrency is presented by time-sharing one processor (software can be designed as if there were multiple threads of control) Coroutines provide only quasi-concurrency Reasons to Study Concurrency It involves a different way of designing software that can be very useful - many real-world situations involve concurrency Computers capable of physical concurrency are now widely used 13.2 Intro to Subprogram-Level Concurrency A task is a program unit that can be in concurrent execution with other program units Tasks differ from ordinary subprograms in that: A task may be implicitly started When a program unit starts the execution of a task, it is not necessarily suspended When a task’s execution is completed, control may not return to the caller Tasks usually work together A task is disjoint if it does not communicate with or affect the execution of any other task in the program in any way Task communication is necessary for synchronization Task communication can be through: Shared nonlocal variables Parameters Message passing
  • 3. ICS 313 - Fundamentals of Programming Languages 3 13.2 Intro to Subprogram-Level Concurrency (continued) Kinds of synchronization Cooperation Task A must wait for task B to complete some specific activity before task A can continue its execution e.g., the producer-consumer problem Competition When two or more tasks must use some resource that cannot be simultaneously used e.g., a shared counter Competition is usually provided by mutually exclusive access Providing synchronization requires a mechanism for delaying task execution Task execution control is maintained by a program called the scheduler, which maps task execution onto available processors Tasks can be in one of several different execution states: New - created but not yet started Runnable or ready - ready to run but not currently running (no available processor) Running Blocked - has been running, but cannot now continue (usually waiting for some event to occur) Dead - no longer active in any sense 13.2 Intro to Subprogram-Level Concurrency (continued) Liveness is a characteristic that a program unit may or may not have In sequential code, it means the unit will eventually complete its execution In a concurrent environment, a task can easily lose its liveness If all tasks in a concurrent environment lose their liveness, it is called deadlock Design Issues for Concurrency How is cooperation synchronization provided? How is competition synchronization provided? How and when do tasks begin and end execution? Are tasks statically or dynamically created? Methods of Providing Synchronization: Semaphores Monitors Message Passing
  • 4. ICS 313 - Fundamentals of Programming Languages 4 13.7 Java Threads The concurrent units in Java are run methods The run method is inherited and overriden in subclasses of the predefined Thread class The Thread Class Includes several methods (besides run) start, which calls run , after which control returns immediately to start yield, which stops execution of the thread and puts it in the task ready queue sleep, which stops execution of the thread and blocks it from execution for the amount of time specified in its parameter Early versions of Java used three more Thread methods suspend, which stops execution of the thread until it is restarted with resume resume, which restarts a suspended thread stop, which kills the thread 13.7 Java Threads (continued) Competition Synchronization with Java Threads A method that includes the synchronized modifier disallows any other method from running on the object while it is in execution If only a part of a method must be run without interference, it can be synchronized Cooperation Synchronization with Java Threads The wait and notify methods are defined in Object, which is the root class in Java, so all objects inherit them The wait method must be called in a loop Example - the queue See Queue class (pp. 549-550) and the Producer and Consumer classes (p. 550)