CSC 543 Multiprocessing & Concurrent Programming, Spring 2021, Wed 6-8:50 PM.
Classes are all via Zoom at class time. Zoom student docs are here.
To watch a recording you *may* first need to go here https://kutztown.zoom.us/ and Sign In using KU login.

My office hours will not change during finals, same as usual. We will meet May 5 @ 6 PM for final presentations.

Dr. Dale E. Parson, http://faculty.kutztown.edu/parson
Class-time Zoom link for CSC543 OR See D2L Course CSC543 -> Content -> Overview for the link.
IF you don’t want to be recorded or are a minor, use PRIVATE ZOOM CHAT to me for questions.
Please fill out & email Dr. Parson this permission to record slip. I will use it to take attendance in week 1.
The course is 100% via Zoom at class time. I will record & post class videos, but want you there at class time. Thanks.
 
parson@kutztown.edu, Office hours: https://kutztown.zoom.us/j/94322223872
Office Hours Monday 2-4, Wednesday 1-3, Thursday 10-11 or by appt.

First day handout (syllabus that is specific to this semester).

I have put a copy of the textbook on reserve in Rohrbach Library for the semester. You can go to the front desk & borrow it overnight.
Students can meet in person in OM 158 OR live on-line via Zoom.
    Please read student instructions here. My instructions for CSC faculty are here.
    I will post links to recorded archives at the bottom of this page within a day after each class.

We will be multiprocessing on mcgonagall.kutztown.edu, which are accessible via ssh from acad:
        ssh -l yourloginname mcgonagall
        ssh -X -l yourloginname mcgonagall  # The -X enables X11 GUI I/O.
 

Handouts from Spring 2011 through present.
Slides for week 2, Chapters 1, 2, 3 and 13 on Introduction, Thread Safety, Sharing Objects and Explicit Locks.
    Week 2 added slides on Race Conditions, Critical Sections & Composing Thread-safe Objects.
    Week 2 Jython code to demonstrate using java.lang.Runnable, java.lang.Thread, and a race condition.
Example code is at /export/home/faculty/parson/multip on acad.kutztown.edu (and on mcgonagall via NFS).
Locks and condition variables slides from September 21 class session.
Slides for week 3, Chapters 15, 16 and Appendix A on Atomic Variables, Nonblocking Synchronization, the Java Memory Model and Annotations for Concurrency. (4/1/2015)
A problem from the Spring 2011 midterm that uses atomic variables instead of a lock-based monitor.
Slides for week 4, Chapter 4 on Composing Objects. (4/1/2015)
    Code listings for Chapter 4
Slides for week 5, Chapter 5 on Building Block Classes from java.util.concurrent. (4/1/2015)
    Code listings for Chapter 5
   
    D. Parson and D. Schwesinger, "Minimum-Blocking Parallel Bidirectional Search,"
            Proceedings of PDPTA'12: 2012 Intl. Conf. on Parallel Processing Techniques and Applications , Las Vegas, NV, July 16 - 20, 2012.
             Here are the slides for the talk.
             CyclicBarrier, CountDownLatch, and using these & related mechanisms in parallel bidirectional search.
             See code on acad at ~parson/multip/pennydime CoinPuzzle CoinPuzzleDataflow & CoinPuzzleDataflowMultiQ.
Slides for week 7, Chapter 6 on using Executor to schedule tasks using thread pools from java.util.concurrent. (4/8/2015)
"Creative Graphical Coding via Pipelined Pixel Manipulation, " Proceedings of the 33rd Annual Spring Conference of the Pennsylvania Computer and Information Science Educators (PACISE) Shippensburg University of PA, Shippensburg, PA, April 6-7, 2018.
Processing (Java) code for sketch PhotoArchMontage and its helper active class ImageLoader demonstrating starting a thread.
    Video and some stills from a digital art exhibit in Munich on September 14, 2018.
    This sketch uses my multithreading package PixelVisitor that we will examine in detail.
    Acad ~parson/multip/PixelVisitor has my Java library for Processing that uses Java thread pools.
Slides for week 10, Chapter 7 on Interruption, Cancellation and Shutdown. (3/25/2015)
More slides for week 10, Chapter 8 on Applying Thread Pools. (4/8/2015)
Slides for week 11, Chapter 9 on GUI Applications. (4/8/2015)
    Tutorial on multithreading in Java FX (GUI framework that supplants Swing.
    Acad ~parson/multip/multip/csc580spring2011/Projects/csc580gps4/gpssearch.java has the Swing example that uses a single-threaded ExecutorService to run the worker thread discussed on 11/30.
More slides for week 11, Chapter 10 on Avoiding Liveness Hazards. (4/15/2015)
Slides for week 12, Chapter 11 on Performance and Scalability. (4/15/2015)
More slides for week 12, Chapter 12 on Testing Concurrent Programs. (4/15/2015)
~parson/Compiler1/optimize5/stepvm/StepVM.java helper class HeapData has the 12/7 example code for lazy evaluation. Search for:
        class HeapData, HeapData.flatten(...), HeapData.helpflatten(...)
        In optimize5/ see collect_reduce.txt (look for reduce and collect), programqsort1p.txt (reduce), programqsort1p_O2.debug.out (STEP_FORK & STEP_JOIN)
        http://acad.kutztown.edu/~parson/javadoc/stepvm/ the STack-based Emulated Processor
Slide on critical sections, race conditions, & related concepts
Slide on deadlock
Example of my Processing visual -> audio work from Cube Fest 2016.
 
Material in my UNIX account
~parson/multip has a lot of documentation & code examples on current programming.
~parson/multip/spring2015 is where I will work out some code examples for class.
~parson/JavaLang/net/jcip/examples has all example code from our textbook.

Older material
Here is my Summer 2010 study of these machines with a January 2015 update for Dumbledore. We will go over this study in class.
Goetz et. al. Java Concurrency in Practice textbook web site. Code exacadamples on  are under ~parson/JavaLang/net/jcip/examples. An on-line copy of the textbook should be available for 45 days via a code in your hard-copy textbook.
Herlihy / Shavit The Art of Multiprocessor Programming web site.
A secure copy of C++ Concurrency in Action is posted here.
A secure copy of Scala in Depth is posted here.
Parallelism on the Desktop, IEEE Software, January/February 2015 (vol. 28 no. 1) (password restricted access).

Assignments -- From acad you must "ssh mcgonagall" to build & test all assignments.

    Assignment 1
on building & running a thread-safe data pipeline is due via make turnitin on February 12.
        See Assignment 1 NOTES ADDED 1/29/2021 on the bottom of page 4 of the Assignment 1 handout.
"Neither the Java Language Specification nor the Java Memory Model formally defines immutability, but immutability is not equivalent to simply declaring all fields of an object final. An object whose fields are all final may still be mutable, since final fields can hold references to mutable objects. An object is immutable if:
  • Its state cannot be modified after construction;
  • All its fields are final; and
  • It is properly constructed (the this reference does not escape during construction).
Immutable objects can still use mutable objects to manage their state. (Parson: No means for class-external mutation.)
See textbook page 47 for more information.
Parson: A marker interface Queue<E> <- java.util.concurrent.ThreadSafeQueue<E> <- BlockingQueue<E> would have allowed pipeline construction using only thread-safe queues. As it stands the Queues may not be @ThreadSafe.

    Assignment 2 on using implicit and explicit locks and condition variables is due via make turnitin by end of March 5.
        A mutex without a condition variable versus a mutex with a condition variable.

    Assignment 3 is on using atomics, semaphores, & writing a thread-safe BlockingQueue.
        It is due via make turnitin by end of March 26.
        Instructions if Jython fails on make genstudent added March 18, see email.

    Assignment 4 on using Executors & Futures for thread pools is due via make turnitin by end of Saturday April 17
        (was: Thursday April 15
).

    Assignment 5 individual mini-projects.
        Talks to be scheduled in class for April 28 & May 5.
        April 28 talks may be work-in-progress.
        Materials are due via D2L by end of May 5 (slides & demo code, prefer zipped).
 
http://docs.oracle.com/javase/8/docs/api/index.html documents the CLASS LIBRARY.

http://www.oracle.com/technetwork/java/javase/downloads/index.html has downloads
       for JDK 1.6 docs and tools (compiler, etc. for Windows).
       Download Java SE Development Kit (JDK) 6 -> Download -> Continue -> Continue,
       then click the file, ignoring the "Sun Download Manager."
       After installing JDK 1.6, go to Windows Control Panel -> System -> Advanced -> Environment Variables and set system variable CLASSPATH to your JavaLang directory. If CLASSPATH is already there, append a semicolon followed by your JavaLang path to the string that is there.
Windows users can download the WinSCP file transfer client in the Computer Science sub-menu below here.

We will go over Java Projects, source editing and debugging in class.

http://www.gnu.org/software/make/manual/  has the make manual.


Zoom Archives
    January 20, First day handout & intro, also collaborative debugging of my intro code example.
        I added comments to this text file copy of GarbledOutput.java plus a few tweaks, please read before the 1/27 class.
    January 27, Extended GarbledOutput.java to demo non-thread-safe vs. thread-safe lists, went over assignment 1.
        See Assignment 1 NOTES ADDED 1/29/2021 on the bottom of page 4 of the Assignment 1 handout.
    February 3, went over Chapters 1, 2, 3 and 13 slides and Chapters 15, 16 and Appendix A slides & Java reflection in assn1.
        Here is my in-class illustration on per-thread stack frames. Each thread gets its own stack of frames.
    February 10, revisited thread-safe construction & publication slides, started Locks, next up: Condition Variables.
        Extended GarbledOutput.java to show Collections.synchronizedList() and @GuardedBy annotation.
    February 17, Went over my solution to Assignment 1, notes on @Immutable, and handed out Assignment 2.
        Please review notes on @Immutable under Assignment 1 above. At least half of Feb. 24 class will be work time.
    February 24, Went over guidance for Tables.java in Assignment 2, slides on Composing Objects, some Assn2 Q&A.
        See slide 20 of week 2 slides "Safe publication idioms (p. 52)", first & last bullet regarding Table.java.
        I will post example of an intrinsic lock & condition variable from GarbledOutput.java within a few days.
        Section 12.4 -- class loader clarifies that the loader asserts a lock on the class until static initialization completes.
        GarbledOutput.java update 2/24 to implement a blocking bounded buffer using an intrinsic lock & condition variable.
            Also added an atomic spin lock 2/26 to have only one active Threader object at a time write into the shared List.
    March 3, Start preview of Assignment 3 & related library classes, also observe synchronization issues with GarbledOutput.
        Here is GarbledOutput.java using a timed wait(10) to avoid starvation; here it is using an interrupt().
    March 17, Went over GarbledOutput on the above line, solution to Assignment 2, handout for Assignment 3.
    March 24, Slides & Javadoc pages on Executors, Futures, thread pools from Chapters 6, 7, &8 slides above.
    March 31, Summarize assn3 & handout assn4, slides on @NotThreadSafe nature of graphical user interface frameworks.
    April 7, Go over the PixelVisitor and related graphical applications of multithreaded bot-mapped image pipelines.
    April 14, Went over Multithreaded Birectional Search variations with code at ~/parson/multip/pennydime,
            also client -> server datagram handling in oscEvent thread using volatiles on client, unbounded thread-safe
            Queue and Immutable data transport between threads in graphical server (oscEvent -> GUI thread).
    April 21, Finished April 14 discussion, examined parallel quicksort benchmark code, Chapters 10, 11, 12 slides.
    April 28, Dr. Parson's demo on parallel process execing from Python and Bob Elward's talk on C# Concurrency.
    May 5, Student presentations of final projects with permission to record.