Using Threads in Interactive Systems: A Case Study

Notes by Ben Cichy 2/98

OBJECTIVE

Examine thread usage in two systems at Xerox Parc - Cedar Programming Environment and Global View for X Windows (GVX) - in an attempt to detect common paradigms and common mistakes of programming with threads.

OVERVIEW

Two types of analysis - dynamic and static. Dynamic examines online thread usage and timing data, static examines code base.

DYNAMIC ANALYSIS

Examining dynamic thread behavior revealed three classes of threads.

  1. Eternal - Repeatedly waiting on Condition Variables
  2. Worker - Performing some activity
  3. Transient - Forked by long-lived threads - execute quickly and die (most numerous)

Other Notes

PARADIGMS (STATIC ANALYSIS)

Classified nine paradigms for working with threads:

  1. Defer Work - (worker threads) - most common, used for interrupt handlers and critical threads
  2. PUMPS - pipeline components - can be used to exploit parallelism, but most often used for programming convenience
  3. Slack Processes - type of PUMP that adds latency to pipeline in hopes of reducing total work done
  4. Sleepers & One Shots - (eternal threads) - long wait for triggering event and then brief execution (one shots exit after executing)
  5. Deadlock Avoiders - (transient) - fork to avoid violating lock order constraints or some other form of deadlock.
  6. Task Rejuvenators - cleanup and recovery from a crashed thread
  7. Serializers - Queue + thread that does work on queue
  8. Concurrency Exploiters - threads that take advantage of multiprocessors and explicit parallelism
  9. Encapsulated Forks - modules that encapsulate paradigm (delayed fork / MBQueue)

ISSUES IN THREAD USE

ISSUES IN THREAD IMPLEMENTATION

DISCUSSION POINTS