O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introduction to C++ Concurrency LiveLessons (Video Training)

Video Description

Introduction to C++ Concurrency LiveLessonsintroduces the principles of concurrency by creating and running simple programs. It not only shows how to write correct code, but also discusses the dangers and pitfalls of concurrency such as data races, deadlocks, livelocks, and more.

 

Description

C++ is undergoing rapid changes to support concurrent and parallel programming. The 2011 Standard introduced a new multicore memory model, atomic variables, threads, asynchronous tasks, and synchronization primitives. Work is being done to add even more support in the future. It’s no longer enough to just learn some new syntax and library API. There’s a need to gain a deeper understanding of the theory and mechanics of concurrency, and Bartosz leads you to that understanding in this video training.

 

About the Instructor

Bartosz Milewskiis the president of Reliable Software, a company that creates high-quality productivity tools for programmers. His work has been widely published in major journals over the past several years, and he is the author of C++ In Action(Addison-Wesley, 2001). During his eight years at Microsoft, he was the development lead of the Content Index component of Windows 2000. He has taught C++ programming at the University of Wroclaw in Poland and holds a Ph.D. in theoretical physics from the University of Wroclaw. He is also involved with the University of Washington, where he participates in graduate courses and seminars in computer science. He is a member of the advisory board at UW Professional and Continuing Education, advising on C/C++ courses.

 

Skill Level

  • Intermediate

 

What You Will Learn

  • Understanding the principles of concurrency and parallelism
  • Understanding the principles of synchronization
  • Writing multithreaded code
  • Understanding common pitfalls of concurrent programming

 

Who Should Take This Course

  • Any C++ programmer with some programming experience who is interested in the exciting topic of concurrency

 

Course Requirements

  • Familiarity with the C++ language

 

Content Description

Lesson 1, "Running an Interactive Demo," shows you the difference that concurrency can make in the behavior of an interactive application. You learn about latency and throughput and the difference between concurrency and parallelism.

Lesson 2, "Starting and Joining Threads," teaches you how to start a thread and what fork/join parallelism is. It also shows you how to pass arguments to threads and talks about thread construction and destruction.

Lesson 3, "Using Threads to Return Values," teaches you how to return data from threads using promises and futures. It shows you how to use async to start threads and tasks and also discusses task-based parallelism.

Lesson 4, "Passing Data Between Threads," teaches you more about passing data between threads. You learn what a data race is and how to avoid it. The lesson describes different ways of passing data that don't introduce data races. This knowledge is then used to implement a program that lists directories in parallel.

Lesson 5, "Working with Mutexes and Locks," demonstrates how to use a mutex and a critical section to protect shared data from races. You learn the basics of the ownership system, which is a systematic way of preventing data races in concurrent programs. You also learn about the limitations of mutexes and locks and their lack of scalability and composability. You see how easy it is to create deadlocks and how to protect your program from them.

Lesson 6, "Using Condition Variables to Communicate," teaches you about the ways threads can communicate with each other. You see a polling example and the use of condition variables. The lesson discusses the client/server architecture, message passing, and the actor model. It also implements a message passing queue and talks about producers and consumers.

Lesson 7, "Understanding the Dangers of Atomic Variables," teaches you about the C++ memory model. It explains what sequential consistency is and how it can be broken. You learn about atomic variables and the dangers of lock-free programming. You also see an example of atomicity violation.

Lesson 8, "Looking into the Future of C++ Concurrency," teaches you about the future of C++ concurrency. It discusses the new ways of composing futures, asynchronous operations, and resumable functions. You also get a taste of programming using software transactional memory.

 

About LiveLessons Video Training

LiveLessons Video Training series publishes hundreds of hands-on, expert-led video tutorials covering a wide selection of technology topics designed to teach you the skills you need to succeed. This professional and personal technology video series features world-leading author instructors published by your trusted technology brands: Addison-Wesley, Cisco Press, IBM Press, Pearson IT Certification, Prentice Hall, Sams, and Que. Topics include IT Certification, Programming, Web Development, Mobile Development, Home and Office Technologies, Business and Management, and more. View all LiveLessons on InformIT at http://www.informit.com/livelessons.

Table of Contents

  1. Introduction
    1. Introduction to C++ Concurrency LiveLessons: Introduction 00:03:27
  2. Lesson 1: Running an Interactive Demo
    1. Learning Objectives 00:00:22
    2. 1.1 Identify an unresponsive application 00:04:38
    3. 1.2 Observe reduced latency 00:03:27
    4. 1.3 Observe parallel performance 00:05:05
  3. Lesson 2: Starting and Joining Threads
    1. Learning Objectives 00:00:23
    2. 2.1 Run a thread 00:04:51
    3. 2.2 Fork multiple threads 00:13:07
    4. 2.3 Start a thread with arguments 00:15:40
  4. Lesson 3: Using Threads to Return Values
    1. Learning Objectives 00:00:23
    2. 3.1 Create a promise and a future 00:12:06
    3. 3.2 Start a thread with std::async 00:06:40
    4. 3.3 Consider using tasks instead of threads 00:04:42
  5. Lesson 4: Passing Data Between Threads
    1. Learning Objectives 00:00:30
    2. 4.1 Understand data races 00:05:58
    3. 4.2 Pass data by value and move 00:11:18
    4. 4.3 Pass immutable data between threads 00:08:24
    5. 4.4 List directories in parallel 00:13:01
  6. Lesson 5: Working with Mutexes and Locks
    1. Learning Objectives 00:00:40
    2. 5.1 Use mutex to protect shared data 00:19:25
    3. 5.2 Familiarize yourself with ownership systems 00:11:30
    4. 5.3 Implement a bank account object with a lock 00:08:47
    5. 5.4 Implement transfer between bank accounts 00:19:05
    6. 5.5 Discover and fix a deadlock 00:09:28
  7. Lesson 6: Using Condition Variables to Communicate
    1. Learning Objectives 00:00:33
    2. 6.1 Create a polling loop 00:07:05
    3. 6.2 Use a condition variable 00:11:38
    4. 6.3 Create a concurrent consumer 00:08:36
    5. 6.4 Implement message passing queue 00:10:42
  8. Lesson 7: Understanding the Dangers of Atomic Variables
    1. Learning Objectives 00:00:28
    2. 7.1 Understand sequential consistency 00:07:27
    3. 7.2 Get acquainted with atomic variables 00:03:31
    4. 7.3 Use atomic variables and run into atomicity violations 00:12:02
  9. Lesson 8: Looking into the Future of C++ Concurrency
    1. Learning Objectives 00:00:26
    2. 8.1 Compose futures using when_all and when_any 00:06:11
    3. 8.2 Compose futures using "then" and resumable functions 00:09:43
    4. 8.3 Learn about transactional memory 00:06:07
  10. Summary
    1. Introduction to C++ Concurrency LiveLessons: Summary 00:02:22