Synchronizing access to shared resources