Implementation of recursive mutex