swebb2066 commented on code in PR #190:
URL: https://github.com/apache/logging-log4cxx/pull/190#discussion_r1096855676


##########
src/main/include/log4cxx/private/mutex.h:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LOG4CXX_PRIV_MUTEX_HDR_
+#define LOG4CXX_PRIV_MUTEX_HDR_
+#include <mutex>
+#include <log4cxx/helpers/loglog.h>
+#include <log4cxx/helpers/stringhelper.h>
+#if !defined(LOG4CXX)
+       #define LOG4CXX 1
+#endif
+#include <log4cxx/private/log4cxx_private.h>
+
+namespace log4cxx
+{
+
+using AppenderMutexType = std::mutex;
+using AppenderScopeGuard = std::lock_guard<AppenderMutexType>;
+using AppenderScopedLock = std::unique_lock<AppenderMutexType>;
+
+// Change mutex attributes to avoid priority inversion problems
+template <class M>
+       void
+EnablePriorityInheritance(M& m, helpers::Pool& p)

Review Comment:
   Using AsyncAppender could reduce the likelihood, but still result in a 
priority inversion. However, AsyncAppender would also increase context 
switching, which is not great on a real time controller.
   
   A priority inversion problem is incredibily hard to verify and in my case 
only appears on deployed systems in the field. You cannot prove its absense 
with even extensive testing.
   
   I believe it is an unfortunate accident of history the glibc does not do 
priority inheritance by default. I guess this is due to the relative recent 
discovery of the priority inversion problem. Fortunately most applications do 
not have real time requirements. However the robotics community (which is a 
significant user of log4cxx - see ROS) really needs configurable logging and 
real time capabilities.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to