We start with help for Projects, then continue with a discussion of C++11 thread code demos and examples.
Glossary of Terms
-
Thread:
A block of processing instructions, defined by a function passed to the operating system (OS), that executes in a processor core, and is started and stopped by the OS. A thread often runs in an environment containing many other threads that are sequenced in short time-slices by the OS to behave like concurrent processing. A thread may run continuously in a core if there are no other threads contending for that resource. -
Lock:
An OS construct that provides ownership to a single thread, making any other thread, that attempts to acquire the lock, wait for the owning thread to release it. Locks are used to provide exclusive access to some resource for reading and writing. A lock has a signaled state that is used to provide blocking of non-owning threads. -
Race Condition:
A body of code has a race condition when the state of its resources depends on the timing of two or more threads. For example, a read/write conflict occurs when one thread begins to modify a resource, a string perhaps, completes its time slice before completing the modification, and another thread reads the, probably invalid, resource. -
Synchronization:
The use of locks to avoid race conditions.
-
Help with Projects:
-
Project #1
Single-user Test Harness. -
Project #2
Local Test Harness -
Project #3
Server Process Pools -
Project #4
Remote Multi-User Test Harness
-
Project #1
-
Synchronous Discussion:
- Go to cppreference.com and lookup Condition_Variable. Be prepared to discuss how that was used in the C++11 Blocking Queue.
-
Threads and Synchronization
Windows and C++11 Threads:
- Motivation:
- The way Windows (and other OSes) work:
- Win32 and C++11 Threads Presentation, pptx
- Win32 Thread Details, doc
-
Simple callable objects demo
Callable objects are very useful for defining thread processing. -
Lambda Capture
Demos for various options when capturing data with lambdas. -
C++11 Concurrency
A series of basic demos that cover most of what you need to know for the midterm and projects. -
Blocking Queue
Thread safe queue that blocks on dequeuing an empty queue. -
Tasks and Threadpool
Provides a ThreadPool class. Task is a wrapper around a static ThreadPool. -
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. -
Asynchronous Systems,
pptx
Presentation on the fundamentals of concurrent systems
The resources, listed below, are less important and you can safely skip for now.-
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. - Create Child Process - MSDN
-
References:
-
Lecture Take-aways:
The most important things we discussed today were: