Synchronization 4: Synthesis

Overview

This is the last lecture.

Summary of last time

Deadlock and lock ordering

Threads and memory

Principles of synchronization

Compare-exchange

bool compare_exchange(std::atomic<T>* value, T* expected, T desired) {
    IN ONE ATOMIC STEP:
    if (*value == *expected) {
        *value = desired;
        return true;
    } else {
        *expected = *value;
        return false;
    }
}

Fairness

Convenience

Implementation of mutexes and condition variables

Atomicity between processes

Atomicity and security

Research!

Next

THANK YOU!

Heart pulse