Refactoring the code for instrumenting sync barriers