linux-sysprog · beginner · ~15 min

Processes after N forks

Reason about exponential process growth.

Challenge

If every existing process calls fork() once at each of n rounds, the process count doubles each round. Implement long processes_after(int n) returning the total after n rounds (starting from 1).

Starter code

long processes_after(int n) {
    /* TODO */
    return 1;
}

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