linux-sysprog · beginner · ~15 min

eventfd counter

Model the additive eventfd counter.

Challenge

An eventfd accumulates the values written to it. Implement long eventfd_total(const long *adds, int n) returning the sum of n writes.

Starter code

long eventfd_total(const long *adds, int n) {
    /* TODO */
    return 0;
}

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