lock and unlock with allowed period handling