Download presentation
Presentation is loading. Please wait.
Published byRandolf Riley Modified over 9 years ago
1
Definitions & Scenarios
2
Acknowledgements This tutorial is based in part on Concurrency: State Models & Java Programming by Jeff Magee and Jeff Kramer.
3
Acknowledgements Tutorial Authors/Creators: Zhen Li, Eileen Kraemer, Zhe Zhao Computer Science Department The University of Georgia
4
Concurrent Program Process & Thread Thread Life Cycle
5
Sequential v. Concurrent Programs consist of subprograms or procedures simpler sets of activities that together make up the overall program Sequential program Subprograms are executed one after the other in fixed order, determined by program’s input Concurrent program The execution of subprograms may overlap in time
6
Computational activities that overlap in time may occur in parallel, or be interleaved. Concurrent Program Parallelism Interleaved
7
In a concurrent program, computational activities are permitted to overlap in time. Concurrent Program Parallelism Interleaved
8
In a concurrent program, computational activities are permitted to overlap in time. Concurrent Program Parallelism Interleaved
9
Process The execution of a sequential program or subprogram A unit of sequential execution A concurrent program consists of multiple processes.
10
Process Parallelism Interleaved Three processes in each figure
11
Thread A method of implementing concurrency Parallelism Interleaved Two different implementations
12
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield suspend resume alive
13
Thread Life Cycle created terminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
14
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
15
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
16
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
17
Thread Life Cycle created terminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
18
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
19
Thread Life Cycle created terminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
20
Thread Life Cycle created terminated Ready (Runnable) running Waiting (Non-runnable) stop dispatch yield resume alive suspend
21
Thread Life Cycle created terminated Ready (Runnable) running Waiting (Non-runnable) stop dispatch yield resume alive suspend
22
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
23
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop yield resume alive suspend
24
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop yield resume alive suspend
25
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
26
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch resume alive suspend
27
Thread Life Cycle createdterminated Ready (Runnable) Waiting (Non-runnable) stop startstop dispatch resume alive suspend running
28
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
29
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive
30
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive
31
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
32
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield alive suspend
33
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield alive suspend
34
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
35
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
36
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive
37
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive
38
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
39
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop start dispatch yield resume alive suspend
40
Thread Life Cycle created terminated Ready (Runnable) running Waiting (Non-runnable) stop start dispatch yield resume alive suspend
41
Thread Life Cycle created terminated Ready (Runnable) running Waiting (Non-runnable) stop dispatch yield resume alive suspend
42
Thread Life Cycle created terminated Ready (Runnable) running Waiting (Non-runnable) stop dispatch yield resume alive suspend
43
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop dispatch yield resume alive suspend
44
Thread Life Cycle createdterminated Ready (Runnable) running Waiting (Non-runnable) stop startstop dispatch yield resume alive suspend
45
Shared Objects Conditional Synchronization Resource Allocation
46
Shared Object Multiple threads have computational activities on the same object Ornamental Garden Garden East Turnstile West Turnstile
47
A Naïve Implementation Garden East Turnstile West Turnstile population thread shared object
48
A Naïve Implementation
49
Problem
51
Race Condition A common flaw in implementing a concurrent program with shared objects Final results depend on the execution sequence of threads Therac-25 accident
52
Mutual Exclusion Access to shared objects should be mutually exclusive in time
53
Solution Lock for atomic operation
54
Solution Lock for atomic operation
56
Review Definitions Concurrency Process & Thread Thread Life Cycle Scenarios Shared Objects – Race Conditions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.