Discovering which critical sections threads are in