Slide design: Dr. Mark L. Hornick

Slides:



Advertisements
Similar presentations
Week 9, Class 3: Model-View-Controller Final Project Worth 2 labs Happens-Before ( SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
Advertisements

CS2852 Week 8, Class 2 Today Tree terminology Non-Binary and Non-Search Trees Tree Traversals (Remaining slides not yet shown) Tomorrow: Quiz Implementing.
SE3910 Week 2, Class 1 Today Basic Circuits Other ??? Tomorrow Lab 2, S365 (Complete prelab BEFORE) Thursday See ScheduleSchedule SE-2811 Slide design:
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
SE-3910 Real-time Systems Week 5, Class 2 – Lab turn-in page is up! – Lost-and-not-found power supply – Quick-Quiz (Ungraded) – Use interrupts in a Linux/C.
Today Quiz Multithreading Options Qt socket buffers between threads Quiz today & Tuesday in lab SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr.
Week 2, Day 2: The Factory Method Pattern Other good design principles Cohesion vs. Coupling Implementing the Strategy Pattern Changing strategies (behaviors)
Week 6, Class 1 & 2: Decorators Return Exam Questions about lab due tomorrow in class? Threads Locking on null object invokeLater & the squares example.
CS-2852 Data Structures Week 5, Class 1 – Testing and Stacks Return Exams & Labs  Package-level access  UML connectors for instance variables Announcement:
SE3910 Week 1, Class 2 Today – Introductions Safety Review Policy The course Tomorrow Lab 1, S365 (Purchase Beaglebone black kit BEFORE) Thursday Class.
Week 3, Day 2: Threads Questions about Threads “Multithreading” in Swing Lab tomorrow: Quiz Lab 3: Threading! SE-2811 Slide design: Dr. Mark L. Hornick.
CS2852 Week 3, Class 2 Today Stacks Queues SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1.
SE-1021 Software Engineering II Week 1, Day 2 Attendance Survey results: Use powerpoint Safety Review Preparation for Lab 1 More on Java fundamentals…
SE-1021 Software Engineering II Week 1, Day 2 Attendance Survey results: Use powerpoint Safety Review Preparation for Lab 1 More on Java fundamentals…
CS2852 Week 6, Class 1 Today The run-time stack Writing and proving recursive methods SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
CS2852 Week 5, Class 2 Today Queue Applications Circular Queue Implementation Testing SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
SE1011 Week 5, Class 1 Today More Java API tools Packages Object Oriented Programming Muddiest Point Tomorrow: Lab 5 – In-lab demo requirements now up.
CS2852 Week 7, Class 1 Today Binary Search Tree Implementing add Implementing find Return Quiz 4 (second attempt) Both sections are graded SE-2811 Slide.
Today Return Quiz First release of final project template Multithreading Options Qt socket buffers between threads Tomorrow: Quiz Interthread communication.
Today Final Project “Preview” Real-time concurrency Multithreading Options pthreads qthreads GPIO.h & GPIO.cpp Quiz tomorrow & Tuesday in lab SE-2811 Slide.
CS2852 Week 6, Class 2 Today Class exercise: Implementing a recursive method Binary Search Trees Tomorrow: Quiz at start of lab Implementing a recursive.
Today Return Quiz First true release of final project (Lab 8) Multithreading Options Qt socket buffers between threads SE-2811 Slide design: Dr. Mark L.
Week 9, Class 3: Java’s Happens-Before Memory Model (Slides used and skipped in class) SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
Week 5, Day 2: Decorator Decorators Muddiest Point Tomorrow: Quiz on lab reading: web.msoe.edu/hasker/se2811/labs/5/ SE-2811 Slide design:
Today Quiz not yet graded Final report requirements posted More on Multithreading Happens-Before in Java SE-2811 Slide design: Dr. Mark L. Hornick Content:
CS2852 Week 3, Class 2 Today Big-O runtime analysis Linked Lists Muddiest Point Lab Quiz Includes writing a method from ArrayList class (See next slide)
Week 7, Class 1: The Command Pattern (cont.) Get Ready for Poll Everywhere Labs 2 & 3 returned Lab 7 due this evening at 11pm Quiz tomorrow at start of.
Week 10, Day 3 Review for the quarter SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1.
Today Quiz not yet graded (Sorry!) More on Multithreading Happens-Before in Java Other langauges with Happens-Before Happens-Before in C++ SE-2811 Slide.
CS2910 Week 7, Class 1 Today Capturing SMTP with Thunderbird Tomorrow Extra office hour at 11 am (right after lab) Friday Office hour cancelled SE-2811.
Week 6, Class 3: Composite Swing composites File composites Computer composites SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
Week 8, Class 3: Model-View-Controller Final Project Worth 2 labs Cleanup of Ducks Reducing coupling Finishing FactoryMethod Cleanup of Singleton SE-2811.
Week 5, Class 3: Decorators Lab questions? Example: Starbuzz coffee Basic Pattern More examples Design Principles Compare with alternatives SE-2811 Slide.
SE2811 Week 8 – Class 2 Re: Lab due tonight SE-2811 Slide design: Dr. Mark L. Hornick Much Content: Dr. Hornick Most Errors: Dr. Yoder 1.
SE3910 Week 8, Class 2 Week 4 Lab: Please return your graded Lab 4 to me so I can enter it in my gradebook Week 7, Class 2 (Wednesday) Half-Exam 2 Done.
SE3910 Week 8, Class 3 Week 4 Lab: Please return your graded Lab 4 to me so I can enter it in my gradebook Week 9 Lab: Individual demos of working sub-modules.
CS-2852 Data Structures Week 5, Class 3 – Testing and Recursion Queue Implementing finite queues Binary Search Recursion Tomorrow – Quiz, Lab demos, Lab.
Threads Some of these slides were originally made by Dr. Roger deBry. They include text, figures, and information from this class’s textbook, Operating.
Slide Style & Content: Dr. Schilling
Slide design: Dr. Mark L. Hornick
Slide design: Dr. Mark L. Hornick
Slide design: Dr. Mark L. Hornick
Slide design: Dr. Mark L. Hornick
Slide design: Dr. Mark L. Hornick
Slide design: Dr. Mark L. Hornick
Week 2, Day 1: The Factory Method Pattern
Polling vs. Interrupts CS2852 7/20/2018
Lecture 25 More Synchronized Data and Producer/Consumer Relationship
Lab: ssh, scp, gdb, valgrind
Polling vs. Interrupts CS2852 9/18/2018
Week 6, Class 2: Observer Pattern
Week 7, Class 1: The Command Pattern (cont.)
Slide design: Dr. Mark L. Hornick
Fall 2018 CISC124 2/24/2019 CISC124 Quiz 1 marking is complete. Quiz average was about 40/60 or 67%. TAs are still grading assn 1. Assn 2 due this Friday,
Slide design: Dr. Mark L. Hornick
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder
Polling vs. Interrupts CS2852 4/21/2019
Week 8, Class 3: Model-View-Controller
Slide design: Dr. Mark L. Hornick
11. MVC SE2811 Software Component Design
Slide design: Dr. Mark L. Hornick
Week 8, Class 3: Model-View-Controller
Slide design: Dr. Mark L. Hornick
11. MVC SE2811 Software Component Design
Slide design: Dr. Mark L. Hornick
Slide design: Dr. Mark L. Hornick
Slide design: Dr. Mark L. Hornick
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder
Week 2 - Friday CS222.
Slide design: Dr. Mark L. Hornick
Presentation transcript:

Slide design: Dr. Mark L. Hornick SE3910 4/24/2019 SE3910 Week 9, Class 3 Today Multithreading in Java and C++11 Monday: Class time -> Office Hours / Demo time (Perhaps in S-365) Full agenda: Return Exam Questions about lab due tomorrow in class? Threads: Locking on null object Threads: invokeLater Threads: The squares example Decorator Class Diagram More on Java IO Class diagrams Design Principles in the patterns we’ve seen so far Compare with alternatives Decorator vs. array approach suggested in class Non-decorator array – decorator can be added on without modifying the original hierarchy Decorator has “before-after” and possibly other combinatorial control that would be hard-coded in array [Show “screenshot” of discussion from class? Or just re-type?] Strategy vs. Decorator class diagrams side-by-side Structural difference (inheritance optional in Strategy pattern?) Decorator vs. “Strategy” array Perhaps next: Coding Starbuzz coffee (?) Add real patterns ArrayList – null-checking Java I/O: Students do coding examples http://stackoverflow.com/questions/9358821/should-i-extend-arraylist-to-add-attributes-that-isnt-null SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder Dr. Josiah Yoder

SE3910 4/24/2019 Lab Announcements To link to OpenCV from Qt, please add these lines at the end of your .pro file: unix: CONFIG += link_pkgconfig unix: PKGCONFIG += opencv If you are getting many underflows, you may want to check that the CPU is set to its maximum frequency. On the BB, run the commands  cpufreq-info cpufreq-set -f 1000MHz  to get the frequency set correctly. (Thanks, Dr. Schilling.) SE-2811 Dr.Yoder Dr. Josiah Yoder

SE3910 4/24/2019 Lab Announcements When checking out a kit for an LCD, check out two kits. If you have any trouble getting it to boot to a Desktop, shutdown and use the other LCD. Or come to my office and borrow mine. When debugging on the desktop, you may want to use a script to automatically capture the output of your commands. e.g., containing: ./mylab8 arguments > output.txt 2> errror.txt Dr. Josiah Yoder

Total and Partial Order SE2811 4/24/2019 Total and Partial Order Each thread has a Total Order Without synchronize or volatile, actions are concurrent ? In a partial order, some “happens-before” relationships are specified, but not all. In a total order, all “happens-before” relationships are specified. (So there is only one way through the program) For any given multithreaded program, different total orders are possible. But from a synchronization perspective, each thread has only one intra-thread total order. This is the “Program order” of that thread. SE-2811 Dr.Yoder Dr. Josiah Yoder

Total and Partial Order SE2811 4/24/2019 Total and Partial Order Partial Order One Total Order In a partial order, some “happens-before” relationships are specified, but not all. In a total order, all “happens-before” relationships are specified. (So there is only one way through the program) SE-2811 Dr.Yoder Dr. Josiah Yoder

Total and Partial Order SE2811 4/24/2019 Total and Partial Order Partial Order One Total Order In a partial order, some “happens-before” relationships are specified, but not all. In a total order, all “happens-before” relationships are specified. (So there is only one way through the program) SE-2811 Dr.Yoder Dr. Josiah Yoder

Total and Partial Order SE2811 4/24/2019 Total and Partial Order Partial Order Another Total Order In a partial order, some “happens-before” relationships are specified, but not all. In a total order, all “happens-before” relationships are specified. (So there is only one way through the program) For any given multithreaded program, different total orders are possible when the program runs. These are called the “Execution order” But from a synchronization perspective, each thread has only one intra-thread total order. SE-2811 Dr.Yoder Dr. Josiah Yoder

Total and Partial Order SE2811 4/24/2019 Total and Partial Order Partial Order Another Total Order In a partial order, some “happens-before” relationships are specified, but not all. In a total order, all “happens-before” relationships are specified. (So there is only one way through the program) For any given multithreaded program, different total orders are possible when the program runs. These are called the “Execution order” But from a synchronization perspective, each thread has only one intra-thread total order. SE-2811 Dr.Yoder Dr. Josiah Yoder

Languages using Happens-Before SE3910 4/24/2019 Languages using Happens-Before Java C++11 Golang LLVM (Technically not a language, but a compiler infrastructure, but it does include an intermediate representation language) http://preshing.com/20130702/the-happens-before-relation/ SE-2811 Dr.Yoder Dr. Josiah Yoder

Happens-Before in C++11 Some are transitive SE3910 4/24/2019 Happens-Before in C++11 Some are transitive “If we ignore consume operations and the dependency-ordered-before relation in C++11, the remaining forms of happens-before end up being transitive.” (Preshing) http://preshing.com/20130702/the-happens-before-relation/ http://en.cppreference.com/w/cpp/atomic/memory_order http://en.cppreference.com/w/cpp/language/eval_order Specifications are notoriously difficult to understand, even the most precise ones. This question clarifies exactly where the C++11 defines what happens-before means. http://stackoverflow.com/questions/34244647/what-does-happens-before-mean-in-the-c11-spec The asker is confused because they say A is true if B is true instead of A is true if and only if B is true. Important to our current discussion: I don’t have access to the C++11 specification. It is not an open standard. You have to purchase a copy, which I have not done. (or at least it doesn’t pop up on Google) SE-2811 Dr.Yoder Dr. Josiah Yoder

Example http://en.cppreference.com/w/cpp/atomic/memory_order SE3910 4/24/2019 Example #include <thread> #include <atomic> #include <cassert> #include <string> std::atomic<std::string*> ptr; int data; void producer() { std::string* p = new std::string("Hello"); data = 42; ptr.store(p, std::memory_order_release); } void consumer() { std::string* p2; while (!(p2 = ptr.load(std::memory_order_acquire))) /* do nothing */; assert(*p2 == "Hello"); // never fires assert(data == 42); // never fires } int main() std::thread t1(producer); std::thread t2(consumer); t1.join(); t2.join(); http://en.cppreference.com/w/cpp/atomic/memory_order SE-2811 Dr.Yoder Dr. Josiah Yoder

Consider this code: synchronized(this) { im = getImage(); q.put(im); } SE3910 4/24/2019 Consider this code: synchronized(this) { im = getImage(); q.put(im); } synchronized(this) { im = q.get(im); display(im); } SE-2811 Dr.Yoder Dr. Josiah Yoder