[openrtm-commit:02622] r2999 - in trunk/OpenRTM-aist/src/lib/coil: . vxworks/coil

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 6月 5日 (月) 08:53:03 JST


Author: miyamoto
Date: 2017-06-05 08:53:03 +0900 (Mon, 05 Jun 2017)
New Revision: 2999

Added:
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Affinity.cpp
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Affinity.h
Modified:
   trunk/OpenRTM-aist/src/lib/coil/CMakeLists.txt
   trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp
Log:
[compat, VxWorks] add Affinity.cpp.

Modified: trunk/OpenRTM-aist/src/lib/coil/CMakeLists.txt
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/CMakeLists.txt	2017-06-01 03:07:43 UTC (rev 2998)
+++ trunk/OpenRTM-aist/src/lib/coil/CMakeLists.txt	2017-06-04 23:53:03 UTC (rev 2999)
@@ -19,10 +19,11 @@
 	common/coil/Timer.cpp
 	common/coil/crc.cpp
 	common/coil/stringutil.cpp
+	vxworks/coil/Affinity.cpp
 	vxworks/coil/Condition.cpp
 	vxworks/coil/DynamicLib.cpp
 	vxworks/coil/Mutex.cpp
-#	vxworks/coil/Routing.cpp
+	vxworks/coil/Routing.cpp
 	vxworks/coil/Process.cpp
 	vxworks/coil/Signal.cpp
 	vxworks/coil/Task.cpp

Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Affinity.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Affinity.cpp	                        (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Affinity.cpp	2017-06-04 23:53:03 UTC (rev 2999)
@@ -0,0 +1,97 @@
+// -*- C++ -*-
+/*!
+ * @file Affinity.cpp
+ * @brief Processor affinity operation class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2016
+ *     Noriaki Ando
+ *     National Institute of
+ *         Advanced Industrial Science and Technology (AIST), Japan
+ *     All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#include <unistd.h>
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#include <pthread.h>
+#endif // _GNU_SOURCE
+#include <coil/stringutil.h>
+#include <coil/Affinity.h>
+
+#include <taskLib.h>
+#include <cpuset.h>
+
+namespace coil
+{
+  bool getProcCpuAffinity(CpuMask& cpu_mask)
+  {
+    return false;
+  }
+
+  bool setProcCpuAffinity(std::vector<unsigned int> mask)
+  {
+    return false;
+  }
+
+  bool setProcCpuAffinity(std::string cpu_mask)
+  {
+    return false;
+  }
+
+  bool getThreadCpuAffinity(CpuMask& cpu_mask)
+  {
+    int pid = taskIdSelf();
+    cpuset_t cpu_set;
+    CPUSET_ZERO (cpu_set);
+    
+    cpu_mask.clear();
+
+    STATUS result = taskCpuAffinityGet(pid, &cpu_set);
+    if (result != OK) { return false; }
+    
+    cpu_mask.push_back((unsigned int)cpu_set);
+    return true;
+  }
+
+  bool setThreadCpuAffinity(std::vector<unsigned int> mask)
+  {
+    int pid = taskIdSelf();
+    cpuset_t cpu_set;
+    CPUSET_ZERO (cpu_set);
+    if(mask.size() > 0)
+    {
+        CPUSET_SET(cpu_set, mask[0]);
+    }
+    else
+    {
+	return false;
+    }
+
+    STATUS result = taskCpuAffinitySet(pid, cpu_set);
+
+
+    if (result != OK) { return false; }
+
+    return true;
+  }
+
+  bool setThreadCpuAffinity(std::string cpu_mask)
+  {
+    coil::vstring tmp = coil::split(cpu_mask, ",", true);
+    CpuMask mask;
+    for (size_t i(0); i < tmp.size(); ++i)
+      {
+        int num;
+        if (coil::stringTo(num, tmp[i].c_str()))
+          {
+            mask.push_back(num);
+          }
+      }
+    return setThreadCpuAffinity(mask);
+  }
+}; // namespace coil

Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Affinity.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Affinity.h	                        (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Affinity.h	2017-06-04 23:53:03 UTC (rev 2999)
@@ -0,0 +1,123 @@
+// -*- C++ -*-
+/*!
+ * @file Affinity.h
+ * @brief  Processor affinity operation class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2016
+ *     Noriaki Ando
+ *     National Institute of
+ *         Advanced Industrial Science and Technology (AIST), Japan
+ *     All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_AFFINITY_H
+#define COIL_AFFINITY_H
+
+#include <string>
+#include <coil/Singleton.h>
+#include <coil/TimeValue.h>
+#include <coil/Mutex.h>
+#include <coil/Guard.h>
+
+
+
+namespace coil
+{
+  typedef std::vector<unsigned int> CpuMask;
+  /*!
+   * @if jp
+   * @brief ¥×¥í¥»¥¹¤ÎCPU affinity¤ò¼èÆÀ¤¹¤ë
+   * @prop cpu_mask ¸½ºßÀßÄꤵ¤ì¤Æ¤¤¤ë affinity ¤¬ CPU ID¤Î
+   *                std::vector<unsigned int> ¤ÇÊÖ¤µ¤ì¤ë¡£
+   * @return True: À®¸ù¡¢False: ¼ºÇÔ
+   * @else
+   * @brief Getting current process CPU affinity
+   * @prop cpu_mask Current CPU affinity mask is returned as CPU ID in
+   *                std::vector<unsigned int>.
+   * @return True: success, False: fail
+   * @endif
+   */
+  bool getProcCpuAffinity(CpuMask& cpu_mask);
+
+  /*!
+   * @if jp
+   * @brief ¥×¥í¥»¥¹¤ÎCPU affinity¤òÀßÄꤹ¤ë
+   * @prop cpu_mask ÀßÄꤹ¤ë CPU affinity ¤ò CPU ID ¤Î
+   *                std::vector<unsigned int> ¥ê¥¹¥È¤ÇÍ¿¤¨¤ë
+   * @return True: À®¸ù¡¢False: ¼ºÇÔ
+   * @else
+   * @brief Setting process CPU affinity
+   * @prop cpu_mask CPU affinity mask to be set is given with CPU ID in
+   *                std::vector<unsigned int> list.
+   * @return True: success, False: fail
+   * @endif
+   */
+  bool setProcCpuAffinity(const CpuMask cpu_mask);
+
+  /*!
+   * @if jp
+   * @brief ¥×¥í¥»¥¹¤ÎCPU affinity¤òʸ»úÎó¤ÇÀßÄꤹ¤ë
+   * @prop cpu_mask ÀßÄꤹ¤ë CPU affinity ¤ò CPU ID ¤Î¥«¥ó¥Þ¶èÀÚ¤êʸ»ú
+   *                Îó¤Î¥ê¥¹¥È¤ÇÍ¿¤¨¤ë
+   * @return True: À®¸ù¡¢False: ¼ºÇÔ
+   * @else
+   * @brief Setting process CPU affinity with string
+   * @prop cpu_mask CPU affinity mask to be set is given with comma
+   *                separated CPU ID string.
+   * @return True: success, False: fail
+   * @endif
+   */
+  bool setProcCpuAffinity(std::string cpu_mask);
+
+  /*!
+   * @if jp
+   * @brief ¥¹¥ì¥Ã¥É¤ÎCPU affinity¤ò¼èÆÀ¤¹¤ë
+   * @prop cpu_mask ¸½ºßÀßÄꤵ¤ì¤Æ¤¤¤ë affinity ¤¬ CPU ID¤Î
+   *                std::vector<unsigned int> ¤ÇÊÖ¤µ¤ì¤ë¡£
+   * @return True: À®¸ù¡¢False: ¼ºÇÔ
+   * @else
+   * @brief Getting current process CPU affinity
+   * @prop cpu_mask Current CPU affinity mask is returned as CPU ID in
+   *                std::vector<unsigned int>.
+   * @return True: success, False: fail
+   * @endif
+   */
+  bool getThreadCpuAffinity(CpuMask& cpu_mask);
+
+  /*!
+   * @if jp
+   * @brief ¥¹¥ì¥Ã¥É¤ÎCPU affinity¤òÀßÄꤹ¤ë
+   * @prop cpu_mask ÀßÄꤹ¤ë CPU affinity ¤ò CPU ID ¤Î
+   *                std::vector<unsigned int> ¥ê¥¹¥È¤ÇÍ¿¤¨¤ë
+   * @return True: À®¸ù¡¢False: ¼ºÇÔ
+   * @else
+   * @brief Setting process CPU affinity
+   * @prop cpu_mask CPU affinity mask to be set is given with CPU ID in
+   *                std::vector<unsigned int> list.
+   * @return True: success, False: fail
+   * @endif
+   */
+  bool setThreadCpuAffinity(const CpuMask cpu_mask);
+
+  /*!
+   * @if jp
+   * @brief ¥¹¥ì¥Ã¥É¤ÎCPU affinity¤òʸ»úÎó¤ÇÀßÄꤹ¤ë
+   * @prop cpu_mask ÀßÄꤹ¤ë CPU affinity ¤ò CPU ID ¤Î¥«¥ó¥Þ¶èÀÚ¤êʸ»ú
+   *                Îó¤Î¥ê¥¹¥È¤ÇÍ¿¤¨¤ë
+   * @return True: À®¸ù¡¢False: ¼ºÇÔ
+   * @else
+   * @brief Setting process CPU affinity with string
+   * @prop cpu_mask CPU affinity mask to be set is given with comma
+   *                separated CPU ID string.
+   * @return True: success, False: fail
+   * @endif
+   */
+  bool setThreadCpuAffinity(std::string mask);
+
+}; // namespace coil
+#endif // COIL_AFFINITY_H

Modified: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp	2017-06-01 03:07:43 UTC (rev 2998)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp	2017-06-04 23:53:03 UTC (rev 2999)
@@ -3,11 +3,12 @@
  * @file  MutexPosix.h
  * @brief RT-Middleware Service interface
  * @date  $Date$
- * @author Nobuhiko Miyamoto <n-miyamoto at aist.go.jp>
+ * @author Noriaki Ando <n-ando at aist.go.jp>
  *
- * Copyright (C) 2017
- *     Nobuhiko Miyamoto
- *     Robot Innovation Research Center
+ * Copyright (C) 2008
+ *     Noriaki Ando
+ *     Task-intelligence Research Group,
+ *     Intelligent Systems Research Institute,
  *     National Institute of
  *         Advanced Industrial Science and Technology (AIST), Japan
  *     All rights reserved.



More information about the openrtm-commit mailing list