Course in POSIX Threads using C

Course in POSIX Threads using C Programming

Bugs in multi-threaded programs are often considered to be the most troublesome issus to get as a programmer. In fact the general rule is to not put them there from start.

If one think that this advise is unrealistic, then the next best advise is to code according to a well-proven set of idioms, which avoid the problems. In this course, we focuses on precisely that strategy.

This is what you will learn
  • Writing multi-threaded programs using POSIX Threads C API
  • Program using C11 Threads
  • Understand and know how to deal with classical concurrency problems
  • Handle mutex locks and condition variables
  • Using semaphores
  • Handle atomic variables
Course Contents

Introduction to Threads and Concurrency

  • Current vs. parallel
  • Scheduling
  • Synchronization
  • Virtual adress space organization
  • Overview of how a function-call is performed and why it's relevant to threads

POSIX Threads

  • Overview of the POSIX Threads C API
  • Creating a thread
  • Passing paramaters to a new thread
  • Configuring threads, like setting the stack-size

The Critical Section Problem

  • Understanding the problem and its solution
  • Three conditions for the critical-section problem
  • POSIX mutex variables
  • Configuration
  • Avoiding self-deadlock
  • Adapting for shared memory

The Race-Condition Problem

  • Understanding the problem and its solution
  • POSIX condition variables
  • Configuration
  • Handling timeouts
  • Adapting for shared memory
  • Understanding monitor semantics
  • The minimum amount of code to safely transfer data from one thread to another

The Deadlock Problem

  • The concept resource
  • Understanding the problem and its solution
  • Four conditions for the deadlock problem
  • Preventing deadlocks
  • Detection of deadlocks

Synchronization and Other Data-Types

  • Read/Write locks
  • Barriers
  • Thread-local storage

Semaphores

  • POSIX semaphores
  • Memory-based vs. file-based semaphores

A C11 Primer

  • Evolution of the C languages
  • C11 highlights
  • Type-generic macros
  • Anonymous structs and unions
  • Static assertions
  • Bounds-checking support

C11 Threads

  • Overview and background of C11 Threads
  • How C11 Threads differs from POSIX Threads
  • Creating threads in C11
  • Waiting for thread termination
  • Mutex variables
  • Condition variables
  • Thread specific data
  • Atomic (lock-free) variables
  • Lock free atomic operations
Facts
NamePOSIX Threads using C
Duration 2 Days
LevelAdvanced
AudienceTechnical C programmers
Prerequisites Practical knowledge and experince of C programming
Tools
  • GCC compiler
  • Jetbrains CLion IDE
  • Ubuntu Linux @ VirtualBox or WSL @ Windows-10
On-Site Course

If you order an On-Site course, we will come to you and hold the course in your office. The price is determined by our price model and is based on the number of course days, number of participants and any travel and lodging.

Read more about out price modell and term of sales here.

Related Courses
CourseDaysLevel
C Programming4 BeginnerShow
Linux Systems Programming using C3AdvancedShow
Threads Programming using Modern C++3AdvancedShow