1 / 56

Concurrency

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

treva
Télécharger la présentation

Concurrency

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Definitions & Scenarios Concurrency

  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 Definitions

  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. Concurrent Program • Computational activities that overlap in time may occur in parallel, or be interleaved. Interleaved Parallelism

  7. Concurrent Program • In a concurrent program, computational activities are permitted to overlap in time. Interleaved Parallelism

  8. Concurrent Program • In a concurrent program, computational activities are permitted to overlap in time. Interleaved Parallelism

  9. Process • The execution of a sequential program or subprogram • A unit of sequential execution • A concurrent program consists of multiple processes.

  10. Process Three processes in each figure Interleaved Parallelism

  11. Thread • A method of implementing concurrency Two different implementations Interleaved Parallelism

  12. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  13. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  14. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  15. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  16. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  17. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  18. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume alive Waiting (Non-runnable)

  19. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  20. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  21. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  22. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  23. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  24. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  25. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  26. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  27. Thread Life Cycle created terminated stop start stop dispatch running Ready (Runnable) yield suspend resume Waiting (Non-runnable) alive

  28. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  29. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  30. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  31. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  32. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  33. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  34. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  35. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  36. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  37. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  38. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  39. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  40. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  41. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  42. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  43. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  44. Thread Life Cycle created terminated stop start stop dispatch Ready (Runnable) running yield suspend resume Waiting (Non-runnable) alive

  45. Shared Objects Conditional Synchronization Resource Allocation Scenarios

  46. Shared Object • Multiple threads have computational activities on the same object • Ornamental Garden Garden East Turnstile West Turnstile

  47. A Naïve Implementation shared object thread thread Garden East Turnstile West Turnstile population

  48. A Naïve Implementation

  49. Problem

  50. Problem

More Related