A Unified Approach to Eliminating Concurrency Bugs via Control Synthesis