Notes The Problem with Threads - Advance Parallels Programming | CISC 879, Study notes of Computer Science

Material Type: Notes; Class: ADVANCED PARALLEL PROGRAMMING; Subject: Computer/Information Sciences; University: University of Delaware; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 09/02/2009

koofers-user-3z5
koofers-user-3z5 🇺🇸

10 documents

1 / 27

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CISC 879 : Software Support for Multicore Architectures
Author – Edward A Lee
Presented by - Varun Notibala
Dept of Computer & Information Sciences
University of Delaware
The Problem with Threads
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download Notes The Problem with Threads - Advance Parallels Programming | CISC 879 and more Study notes Computer Science in PDF only on Docsity!

Author – Edward A Lee

Presented by - Varun Notibala

Dept of Computer & Information Sciences University of Delaware The Problem with Threads

Threads

  • Thread : single sequential flow of control
    • Model for concurrent programming
  • Sequential computation
    • Understandable, predictable, deterministic
  • Threads result in loss of these features
  • Methods to limit / eliminate these losses available
    • But, not effective

Problem w/ threads – WHY?

  • Concurrent abstractions chosen for threads
    • Don’t represent concurrency in real world
  • Concurrent programming using threads hard
  • MAIN IDEA Replace sequence of steps with community of interacting entities

Some terminology

  • Determinacy
  • Predictability
  • Reliability
  • Pruning

Example - Observer Pattern

public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valueChanged(int newValue); } public void addListener(Listener listener) { listeners.add(listener); }

Example - Observer Pattern

public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valueChanged(int newValue); } public void addListener(Listener listener) { listeners.add(listener); } public void setValue(int newValue) { value = newValue; Iterator i = listeners.iterator(); while(i.hasNext()) { ((Listener)i.next()) .value Changed(newValue); }

Example - Observer Pattern

public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valueChanged(int newValue); } public synchronized void addListener(Listener listener) { listeners.add(listener); } public void setValue(int newValue) { List copyOfListeners; synchronized(this) { value = newValue; copyOfListeners = new LinkedList(listeners); } Iterator i = copyOfListeners.iterator() ; while(i.hasNext()) { ((Listener)i.next()).value Changed(newValue); }

Observer pattern - Inference

  • Prone to deadlocks
  • Concurrent modification clash
  • Most multithreaded programs have concurrency issues
  • Multi-core architectures
    • Will concurrency bugs might show up more often ??

Aggressive pruning

  • Design patterns – transactional design
    • Work on a data copy followed by commit or abort
    • Transactions suited for intrinsic non- deterministic interactions
    • But not to build determinate concurrent interactions
  • Patterns encapsulated into libraries – concurrent data structures in Java 5.

Aggressive pruning

  • Extension of languages with keywords - Split-C, Cilk
  • Gauva language constrains java to prohibit access of unsynchronised objects from multiple threads
  • Explicit separation of read and write locks
  • Promises
  • Formal program analysis like Blast and Intel thread checker to identify potential concurrency bugs

Alternatives to threads

Observer pattern implemented using rendezvous based coordination language

  • Each component is a process
  • Merge block specifies a conditional rendezvous
  • Two possible three way rendezvous interactions

Alternatives to threads

  • The merge block represents the co-ordination language
  • This handles the synchronization
  • It can be implemented using other design models –
    • PN Director – Kahn process network for concurrency
    • SR Director – Synchronous reactive director

Overcoming non-

determinism

Deterministic interleaving using rendezvous

Alternatives to threads -

Inference

  • Split design into deterministic stand alone blocks
  • Introduce non-determinism judiciously
  • This style of concurrency is AKA “actor oriented” design - Supplement of control flow oriented design
  • Some examples of actor oriented design
    • OpenMP
    • MPI