JavaPThreads

JavaPThreads - Shared memory programming with Java and...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Shared memory programming with Java and Pthreads Thanks to LLNL for their tutorial from which these slides are derived http://www.llnl.gov/computing/tutorials/ workshops/workshop/pthreads/MAIN.html Friday, January 27, 12
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
• Many Java Virtual Machines use Pthreads to support their threading model • We will first cover threads in general, and then Java threads, and then Pthreads • For projects, you can use either Java, Pthreads (with C/C++ or Fortran) or OpenMP for shared memory programming • Some homeworks require you to use either Java or Pthreads • Java programming is not required 2 Friday, January 27, 12
Background image of page 2
Multithreading in Java Friday, January 27, 12
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Multithreading a part of the language Language speciFcation attempts to deFne what happens in programs with races not true with C/C++ & Pthreads these have “catch Fre” semantics in the case of races Standard library calls for mutex synchronization, thread safe libraries, standard calls for thread creation, destruction, and so forth Friday, January 27, 12
Background image of page 4
Java Basics .java fles .java fles .java fles javac compiler ..class fles .class fles .class fles java virtual machine jit compiler interpreter classloader mem. mgmt. scheduler OS/external services network input output Friday, January 27, 12
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Java Basics .java .java .java javac compiler ..class .class .class java virtual machine jit compiler interpreter classloader mem. mgmt. scheduler OS/external input output Supplies basic OS-like services to a program Scheduling Resource management Isolation Any program executed must be limited in the damage it can cause internally, this makes many things hard in particular, races have to have reasonable (i.e. not “catch fre” semantics. Friday, January 27, 12
Background image of page 6
java virtual machine classes shared memory -- heap, stacks, etc. A simple view of the JVM .class fles network input output main t0 t3 t2 t1 ... tn Friday, January 27, 12
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Java is an object oriented language Objects are a way to organize data and code that operates on that data You can think of an object as a collection of routines and a struct that holds the object's data Objects also support stuff like overloading, polymorphism, inheritance and data encapsulation That is the subject of another course and will be discussed then A class deFnes what data and code an object contains, and objects are instances of that class Friday, January 27, 12
Background image of page 8
Reconsider OpenMP Critical What keeps the critical section in different threads from overlapping? A lock #pragma omp parallel for for (i=0; i < n; i++) { #pragma omp critical t += a[i]; } i=0 t=t+a[0] . . . . time = i=1 t=t+a[1] i=n-1 t=t+a[n-1] Friday, January 27, 12
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Locks A lock , sometimes called a mutex (for mutual exclusion) lock typically have the properties: at most one thread can hold the lock at a time when a thread tries to acquire a lock that is held, it joins a queue to wait to get the lock while in the wait queue the lock does no work when the lock is released by the thread that holds it,
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/19/2012 for the course ECE 563 taught by Professor Staff during the Spring '08 term at Purdue.

Page1 / 88

JavaPThreads - Shared memory programming with Java and...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online