SlideServe
Menu
Préférences
© SlideServe · v2026

Transactional Memory: Rethinking Condition Variables for Efficient Thread Synchronization

tate avatar
32 diapositives · 452 Views · Nov 01, 2013

Reevaluation of condition variables in transactional memory for robust synchronization primitives. Our research focuses on developing TM-compatible condition variables with implementation independence and comparable performance to original CVs. We analyze past lessons, propose new ideas, and study Transaction/Condition Variable Interactions. Evaluate TM-safe Condition Variables and the performance of TM-CV Implementations under various workloads.

Transactional Memory: Rethinking Condition Variables for Efficient Thread Synchronization - slide 1
01 / 32Transactional Memory: Rethinking Condition Variables for Efficient Thread Synchronization
1 / 17

Télécharger la présentation

Transactional Memory: Rethinking Condition Variables for Efficient Thread Synchronization
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Polina Dudnik and Michael Swift University of Wisconsin, Madison Condition Variables and Transactional Memory: Problem or Opportunity?

  2. Executive Summary • Problem: thread synchronization in TM • Goal: robust synchronization primitive • State of the art: Retry/orelse • Main point: Condition Variables [CVs] still relevant • Our contributions: • TM-compatible condition variables • Implementation independent • Performance comparable to original CVs

  3. Outline • Lessons from the past • New ideas for TM • Transaction/Condition Variable Interactions • Design of TM-safe Condition Variables • Evaluation

  4. What is the problem? • How should threads coordinate? • How should threads wait for an event or state change? • How does this problem change with transactions?

  5. On the Road to CVs • Semaphores [Dijkstra ‘65] • Condition Critical Regions (CCRs) [Hoare ‘72]

  6. Hoare on CCR • I feel this proposal [condition critical regions] is not suitable for operating system implementation. My proposed method encourages the programmer to ignore the question of which of several outstanding requests for a resource should be granted. • Sir Anthony Hoare [Belfast ‘71]

  7. Limitations of CCR • Atomicity • Excessive Context Switching • Restrictive Scheduling

  8. Solution: Condition Variables • Condition variable = queue of waiters • Associated lock maintains mutual exclusion • Signaling a CV = hint that state has changed [Mesa semantics: Lampson ‘79] • Multiple CVs provide prioritized wakeup

  9. Problem Solved • CCR • Atomicity Concerns • Performance Issues • Restrictive Scheduling • Condition Variables • Monitors • Precise Wakeup • Explicit Signaling/Multiple CVs

  10. CVs Limitations • Nested monitor problem • How about nested function calls? • Or waiting on two event queues? • Retry/orelse solves these problems!

  11. TM Synchronization Today • Retry/orelse [Harris et al. 2005]

  12. Why not retry? • Nesting • Composability • Restrictive scheduling • Potentially poor scalability • Other proposals have the same problems: • atomic CCRs [Harris 2003], atomic Wait [Smaragdakis 2007], X10 conditional atomic blocks [Charles 2005] • It is too early to give up on condition variables!

  13. Outline • Lessons from the past • New ideas • Transaction/Condition Variable Interactions • Design of TM-safe Condition Variables • Evaluation

  14. TM Condition Variables • Original condition variables • int get() { • lock(l); • getters++; • while (!available) { • wait(cv, l); • } • getters--; • available = false; • unlock(l); • return contents; • }

  15. TM Condition Variables • Convert locks to transactions • int get() { • begin_tx; • getters++; • while (!available) { • wait(cv); • } • getters--; • available = false; • end_tx; • return contents; • }

  16. TM Condition Variables • Wait outside the transaction • int get() { • begin_tx; • getters++; • while (!available) { • end_tx; • wait(cv); • begin_tx; • } • getters--; • available = false; • end_tx; • return contents; • }

  17. Lost Wakeup • Waiting Thread • begin_tx; • read_state; • prepare_wait(); • end_tx; • wait(); • Signaling Thread • begin_tx; • update_state; • signal(); • end_tx; TIME

  18. TM Condition Variables • Split wait • prepare wait within transaction • commit • complete wait • restart transaction • int get() { • begin_tx; • getters++; • while (!available) { • prepare_wait(cv); • end_tx; • complete_wait(cv); • begin_tx; • } • getters--; • available = false; • end_tx; • return contents; • }

  19. TM Condition Variables • What happens with concurrent signalers? • int get() { • begin_tx; • getters++; • while (!available) { • prepare_wait(cv); • end_tx; • complete_wait(cv); • begin_tx; • } • getters--; • available = false; • end_tx; • return contents; • }

  20. Update-Signal Order • Waiting Thread • begin_tx; • while (!state) { • prepare_wait(); • end_tx; • wait(); • begin_tx; • } • end_tx; • Signaling Thread • begin_tx; • update_state; • signal(); • end_tx; TIME

  21. TM-CV Implementations

  22. Outline • Lessons from the past • New ideas for TM • Transaction/Condition Variable Interactions • Design of TM-safe Condition Variables • Evaluation

  23. Workloads • libMicro • Stress-test of conditional synchronization • FluidAnimate PARSEC • Many critical sections, few condition variables ops • StreamCluster PARSEC • Few critical sections, few condition variable ops • Platform: Solaris + GEMS/LogTM-SE, 16 threads

  24. Evaluation • Questions to answer: • Does it work? • How two versions compare in performance? • How does performance compare to locks?

  25. Results

  26. Evaluation • Answers to questions: • Does it work? • YES • How two versions compare in performance? • Differ under stress • How does performance compare to locks? • Comparable performace

  27. Conclusions • Condition Variables are still relevant with TM • Two implementations of TM-CV • Different requirements on TM system • Performance difference subject to potential overlap • Read the paper for: • Implementation independence

  28. QUESTIONS?

  29. Backup Slides

  30. Different Colors

  31. Example CV usage • void BeginWrite() { • pthread_mutex_lock(mutex); • while (NWriters == 1 || NReaders > 0){ • ++WaitingWriters; • pthread_cond_wait(CanWrite,mutex); • --WaitingWriters; • } • NWriters = 1; • pthread_mutex_unlock(mutex}; • }

  32. Lost Wakeup • Waiting Thread • BEGIN_TX • while (!state) { • prepare_wait() • COMMIT_TX • wait() • BEGIN_TX • } • COMMIT_TX • Signaling Thread • BEGIN_TX • update_state • BEGIN_ESCAPE • signal() • END_ESCAPE • COMMIT_TX