linux-sysprog · beginner · ~15 min

Is the operation atomic?

Tell race-safe operations from racy ones.

Challenge

Implement int op_is_safe(const char *op) returning 1 for "atomic_fetch_add" or "mutex_guarded" and 0 for "plain_plusplus".

Starter code

#include <string.h>

int op_is_safe(const char *op) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.