Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC364 Lecture 15

CSC364 Lecture 15

Introduction to Networked, Distributed, and Parallel Computing
Connecting the Dots
(202603)

Avatar for Javier Gonzalez-Sanchez

Javier Gonzalez-Sanchez PRO

March 02, 2026

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 364 Introduction to Networked, Distributed, and Parallel Computing Lecture 15. Connecting the Dots 1
  2. 8 De f inition • Work f lows through st

    a ges (thre a ds), typic a lly connected by blocking queues. • E a ch st a ge runs concurrently.
  3. 9 Class Condition • A Condition object represents a st

    a te predic a te th a t thre a ds c a n w a it for while holding a lock. • E a ch Condition is tied to one speci f ic lock When a thre a d c a lls a w a it(): • It rele a ses the lock • It goes to sleep When sign a led: • It re- a cquires the lock • Execution resumes a fter a w a it()
  4. 26 De f inition A BlockingQueue is a thre a

    d-s a fe queue th a t a utom a tic a lly h a ndles: • Mutu a l exclusion • W a iting when empty • W a iting when full
  5. 27 De f inition It removes the need to m

    a nu a lly write: lock.lock(); while(condition) { await(); } ... signal(); lock.unlock();
  6. 28 Methods put(E e) • Inserts a n element •

    If the queue is full → the thre a d blocks until sp a ce is a v a il a ble t a ke() • Removes a nd returns the he a d • If the queue is empty → the thre a d blocks until a n element is a v a il a ble
  7. 29 Solution No busy w a iting. No m a

    nu a l condition v a ri a bles. No m a nu a l sign a l. It directly solves the Producer–Consumer problem. It helps with Pipeline connection
  8. CSC 364 Introduction to Introduction to Networked, Distributed, and Parallel

    Computing Javier Gonzalez-Sanchez, Ph.D. [email protected] Winter 2026 Copyright. These slides can only be used as study material for the class CSC 364 at Cal Poly. They cannot be distributed or used for another purpose. 34