linux-sysprog · beginner · ~15 min
Track lock state at a point in time.
Implement int in_critical_section(const char *ops, int k) returning 1 if the mutex is held immediately after processing the first k ops ('l'=lock, 'u'=unlock), else 0.
int in_critical_section(const char *ops, int k) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.