C C T B H P N

Lecture #13 - Processes and Threads

Win32 Threading

Web Resources:

CppCon - 2014, Going Native 2013
Herb Sutter's Blog, Herb Sutter on C++11, Herb Sutter keynote - Going Native 2012
Scott Meyer's Blog, S.M. on thread suspension, S.M.: C++11 Sampler
Stroustrup's Home Page
Code Project, Boost Library
Excellent C++ Q&A, Excellent reference - CppReference.com, CPlusPlus.com, C++ TechLinks

Content:

This lecture covers Win32 Processes and Threads.
  1. Readings:

    The C++ Standard Library, Nicolai Jusuttis, Chap 18: Concurrency
  2. Syllabus
    Describes topics to be covered, reading material for you to digest before coming to class, and due dates for the assigned projects.
  3. Projects:

    Resources for Project #2: - Source code publisher for projects
    Project #2 statement, Project2HelpS2019
    Project Details OODProject2Helper adds show/hide capability to the demo output. I've posted Ammar Salman's solution for Project #1, and an updated version of the Parser with an Executive, in the Project2HelpS19 folder. I recommend its use for Project #2. You will also find the Parser Blog helpful for Project #2. C++ Survival Guide, doc
    Visual Studio help notes, Code Analyzer
    Project Submissions

    Current Versions of Code:

    If you go to other folders in the college server you are very likely to download out-of-date code, usually correct, but won't compile with demonstration code that uses newer features.
    Policy for due date extensions - only for certified illness and work or interview trips out of town:
    one week extension, with proof. Only one extension per project.
  4. Selected STL Containers

    STL-Containers - you may need for Midterm
    • std::Deque<T> - indexable elements, constant-time access with push_front, pop_front, push_back, pop_back, operator[]
    • std::List<T> - constant-time access to either end with push_front, pop_front, push_back, pop_back
    • std::unordered_map<Key, Value> - almost constant time access using key
    • std::stack<T> - constant-time access to top with push and pop
    • std::vector<T> - indexable elements, constant-time access, linear-time erasure.
    Container Iteration Demo
  5. Callable Objects:

    Simple Demo of Callable Objects, Callable Objects Examples
    Illustrates use of functions, function pointers, std::function<R(A...)>, lambdas, and lamda closures.
  6. Threads and Synchronization

    Create Child Process - MSDN
    csdialog demo - why we need threads
    Process Diagram, vsdx, Memory Mapped Files, vsdx
    Windows message processing, Windows GUI structure
    Win32 and C++11 Threads Presentation, pptx
    Win32 Thread Details, doc
    Simple callable objects demo
    Callable objects are often used to define a thread's processing.
    Simple C++ Consurrency Demo
    Place to start learning about C++11 threading.
    C++11 Concurrency
    A series of basic demos that cover most of what you need to know for the midterm and projects.
    Make sure you learn how to pass arguments to threads and how they can return results.
    Threads with callbacks
    Callbacks are application supplied functions that are called when a thread completes its assigned processing, usually to return results.
    Blocking Queue
    Thread safe queue that blocks on dequeuing an empty queue.
    Lambda Capture
    Demos for various options when capturing data with lambdas.
    C++11 Thread Techniques
    Illustrations of how to do interesting things that are often needed in project designs.
    Queued Messages
    Passes messages between threads using Blocking Queue.
    Tasks and Threadpool
    Provides a ThreadPool class. Task is a wrapper around a static ThreadPool.
    Custom Threads and Locks Classes
    C++ class encapsulating Win32 threads. This was written before C++11 and is included only to show how creating a thread class can be accomplished.

    References:

    CppReference.com
    Concurrency in C++11 - UChicago

    Articles by Kenny Kerr, MSDN

    Evolution of Synchronization in Windows and C++
    Evoluton of Threads and I/O in Windows
    Building C++11 Semaphores
    Pursuit of Efficient and Composable Asynchronous Systems
    Back to the Future with Resumable Functions
  7. Software Design Blog Entries:
  8. Software design presentations: There is no receipe for good design - it's a creative process that usually strives to balance a number of competing factors. Our goals are to build programs and software systems that are elegant and simple, make their intents clear, and make them fast and reliable. The presentations below provide guidance to help move us toward those goals.
    Software Design Goals, ppt
    Design Goals and Attributes - used to measure designs. Design Strategies, pptx
    Discusses styles of design and binding. Design Guidelines, pptx
    Small principles and useful techniques Design Issues, pptx
    Practical issues and problems of design and implementation
  9. These are the most important items from today's lecture:

CST strip