The mutex needs to be a global that is instantiated early in order to work in all contexts.