570 likes | 734 Views
Definitions & Scenarios. Concurrency. Acknowledgements. This tutorial is based in part on Concurrency: State Models & Java Programming by Jeff Magee and Jeff Kramer. Acknowledgements. Tutorial Authors/Creators: Zhen Li, Eileen Kraemer, Zhe Zhao Computer Science Department
E N D
Definitions & Scenarios Concurrency
Acknowledgements • This tutorial is based in part on Concurrency: State Models & Java Programming by Jeff Magee and Jeff Kramer.
Acknowledgements • Tutorial Authors/Creators: Zhen Li, Eileen Kraemer, Zhe Zhao Computer Science Department The University of Georgia
Concurrent Program Process & Thread Thread Life Cycle Definitions
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
Concurrent Program • Computational activities that overlap in time may occur in parallel, or be interleaved. Interleaved Parallelism
Concurrent Program • In a concurrent program, computational activities are permitted to overlap in time. Interleaved Parallelism
Concurrent Program • In a concurrent program, computational activities are permitted to overlap in time. Interleaved Parallelism
Process • The execution of a sequential program or subprogram • A unit of sequential execution • A concurrent program consists of multiple processes.
Process Three processes in each figure Interleaved Parallelism
Thread • A method of implementing concurrency Two different implementations Interleaved Parallelism
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume alive Waiting (Non-runnable)
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch running Ready (Runnable) yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive
Shared Objects Conditional Synchronization Resource Allocation Scenarios
Shared Object • Multiple threads have computational activities on the same object • Ornamental Garden Garden East Turnstile West Turnstile
A Naïve Implementation shared object thread thread Garden East Turnstile West Turnstile population