[Xenomai-git] Philippe Gerum : lib/cobalt: group process scheduling calls

2015-10-06 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 2d6661e832ec83298ced89fcb71febfc6836b410
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2d6661e832ec83298ced89fcb71febfc6836b410

Author: Philippe Gerum 
Date:   Thu Sep 17 00:46:13 2015 +0200

lib/cobalt: group process scheduling calls

---

 lib/cobalt/Makefile.am |1 +
 lib/cobalt/sched.c |  390 
 lib/cobalt/thread.c|  345 --
 3 files changed, 391 insertions(+), 345 deletions(-)

diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 2bfc3e3..576122d 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -25,6 +25,7 @@ libcobalt_la_SOURCES =\
mutex.c \
printf.c\
rtdm.c  \
+   sched.c \
select.c\
semaphore.c \
signal.c\
diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c
new file mode 100644
index 000..b0be725
--- /dev/null
+++ b/lib/cobalt/sched.c
@@ -0,0 +1,390 @@
+/*
+ * Copyright (C) 2005-2015 Philippe Gerum .
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "current.h"
+#include "internal.h"
+
+/**
+ * @ingroup cobalt_api
+ * @defgroup cobalt_api_scheduler Process scheduling
+ *
+ * Cobalt/POSIX process scheduling
+ *
+ * @see
+ * http://pubs.opengroup.org/onlinepubs/95399/functions/xsh_chap02_08.html#tag_02_08_04";>
+ * Specification.
+ *
+ *@{
+ */
+
+/**
+ * Yield the processor.
+ *
+ * This function move the current thread at the end of its priority group.
+ *
+ * @retval 0
+ *
+ * @see
+ * http://www.opengroup.org/onlinepubs/95399/functions/sched_yield.html";>
+ * Specification.
+ *
+ */
+COBALT_IMPL(int, sched_yield, (void))
+{
+   if (cobalt_get_current() == XN_NO_HANDLE ||
+   (cobalt_get_current_mode() & (XNWEAK|XNRELAX)) == (XNWEAK|XNRELAX))
+   return __STD(sched_yield());
+
+   return -XENOMAI_SYSCALL0(sc_cobalt_sched_yield);
+}
+
+/**
+ * Get minimum priority of the specified scheduling policy.
+ *
+ * This service returns the minimum priority of the scheduling policy @a
+ * policy.
+ *
+ * @param policy scheduling policy.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a policy is invalid.
+ *
+ * @see
+ * http://www.opengroup.org/onlinepubs/95399/functions/sched_get_priority_min.html";>
+ * Specification.
+ *
+ */
+COBALT_IMPL(int, sched_get_priority_min, (int policy))
+{
+   int ret;
+
+   switch (policy) {
+   case SCHED_FIFO:
+   case SCHED_RR:
+   break;
+   default:
+   ret = XENOMAI_SYSCALL1(sc_cobalt_sched_minprio, policy);
+   if (ret >= 0)
+   return ret;
+   if (ret != -EINVAL) {
+   errno = -ret;
+   return -1;
+   }
+   }
+
+   return __STD(sched_get_priority_min(policy));
+}
+
+/**
+ * Get extended minimum priority of the specified scheduling policy.
+ *
+ * This service returns the minimum priority of the scheduling policy
+ * @a policy, reflecting any Cobalt extension to the standard classes.
+ *
+ * @param policy scheduling policy.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a policy is invalid.
+ *
+ * @see
+ * http://www.opengroup.org/onlinepubs/95399/functions/sched_get_priority_min.html";>
+ * Specification.
+ *
+ */
+int sched_get_priority_min_ex(int policy)
+{
+   int ret;
+
+   ret = XENOMAI_SYSCALL1(sc_cobalt_sched_minprio, policy);
+   if (ret >= 0)
+   return ret;
+   if (ret != -EINVAL) {
+   errno = -ret;
+   return -1;
+   }
+
+   return __STD(sched_get_priority_min(policy));
+}
+
+/**
+ * Get maximum priority of the specified scheduling policy.
+ *
+ * This service returns the maximum priority of the scheduling policy @a
+ * policy.
+ *
+ * @param policy scheduling policy.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a policy is invalid.

[Xenomai-git] Philippe Gerum : lib/cobalt: group process scheduling calls

2015-10-03 Thread git repository hosting
Module: xenomai-3
Branch: arm64
Commit: 2d6661e832ec83298ced89fcb71febfc6836b410
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2d6661e832ec83298ced89fcb71febfc6836b410

Author: Philippe Gerum 
Date:   Thu Sep 17 00:46:13 2015 +0200

lib/cobalt: group process scheduling calls

---

 lib/cobalt/Makefile.am |1 +
 lib/cobalt/sched.c |  390 
 lib/cobalt/thread.c|  345 --
 3 files changed, 391 insertions(+), 345 deletions(-)

diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 2bfc3e3..576122d 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -25,6 +25,7 @@ libcobalt_la_SOURCES =\
mutex.c \
printf.c\
rtdm.c  \
+   sched.c \
select.c\
semaphore.c \
signal.c\
diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c
new file mode 100644
index 000..b0be725
--- /dev/null
+++ b/lib/cobalt/sched.c
@@ -0,0 +1,390 @@
+/*
+ * Copyright (C) 2005-2015 Philippe Gerum .
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "current.h"
+#include "internal.h"
+
+/**
+ * @ingroup cobalt_api
+ * @defgroup cobalt_api_scheduler Process scheduling
+ *
+ * Cobalt/POSIX process scheduling
+ *
+ * @see
+ * http://pubs.opengroup.org/onlinepubs/95399/functions/xsh_chap02_08.html#tag_02_08_04";>
+ * Specification.
+ *
+ *@{
+ */
+
+/**
+ * Yield the processor.
+ *
+ * This function move the current thread at the end of its priority group.
+ *
+ * @retval 0
+ *
+ * @see
+ * http://www.opengroup.org/onlinepubs/95399/functions/sched_yield.html";>
+ * Specification.
+ *
+ */
+COBALT_IMPL(int, sched_yield, (void))
+{
+   if (cobalt_get_current() == XN_NO_HANDLE ||
+   (cobalt_get_current_mode() & (XNWEAK|XNRELAX)) == (XNWEAK|XNRELAX))
+   return __STD(sched_yield());
+
+   return -XENOMAI_SYSCALL0(sc_cobalt_sched_yield);
+}
+
+/**
+ * Get minimum priority of the specified scheduling policy.
+ *
+ * This service returns the minimum priority of the scheduling policy @a
+ * policy.
+ *
+ * @param policy scheduling policy.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a policy is invalid.
+ *
+ * @see
+ * http://www.opengroup.org/onlinepubs/95399/functions/sched_get_priority_min.html";>
+ * Specification.
+ *
+ */
+COBALT_IMPL(int, sched_get_priority_min, (int policy))
+{
+   int ret;
+
+   switch (policy) {
+   case SCHED_FIFO:
+   case SCHED_RR:
+   break;
+   default:
+   ret = XENOMAI_SYSCALL1(sc_cobalt_sched_minprio, policy);
+   if (ret >= 0)
+   return ret;
+   if (ret != -EINVAL) {
+   errno = -ret;
+   return -1;
+   }
+   }
+
+   return __STD(sched_get_priority_min(policy));
+}
+
+/**
+ * Get extended minimum priority of the specified scheduling policy.
+ *
+ * This service returns the minimum priority of the scheduling policy
+ * @a policy, reflecting any Cobalt extension to the standard classes.
+ *
+ * @param policy scheduling policy.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a policy is invalid.
+ *
+ * @see
+ * http://www.opengroup.org/onlinepubs/95399/functions/sched_get_priority_min.html";>
+ * Specification.
+ *
+ */
+int sched_get_priority_min_ex(int policy)
+{
+   int ret;
+
+   ret = XENOMAI_SYSCALL1(sc_cobalt_sched_minprio, policy);
+   if (ret >= 0)
+   return ret;
+   if (ret != -EINVAL) {
+   errno = -ret;
+   return -1;
+   }
+
+   return __STD(sched_get_priority_min(policy));
+}
+
+/**
+ * Get maximum priority of the specified scheduling policy.
+ *
+ * This service returns the maximum priority of the scheduling policy @a
+ * policy.
+ *
+ * @param policy scheduling policy.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a policy is invalid.

[Xenomai-git] Philippe Gerum : lib/cobalt: group process scheduling calls

2015-09-30 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 2d6661e832ec83298ced89fcb71febfc6836b410
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2d6661e832ec83298ced89fcb71febfc6836b410

Author: Philippe Gerum 
Date:   Thu Sep 17 00:46:13 2015 +0200

lib/cobalt: group process scheduling calls

---

 lib/cobalt/Makefile.am |1 +
 lib/cobalt/sched.c |  390 
 lib/cobalt/thread.c|  345 --
 3 files changed, 391 insertions(+), 345 deletions(-)

diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 2bfc3e3..576122d 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -25,6 +25,7 @@ libcobalt_la_SOURCES =\
mutex.c \
printf.c\
rtdm.c  \
+   sched.c \
select.c\
semaphore.c \
signal.c\
diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c
new file mode 100644
index 000..b0be725
--- /dev/null
+++ b/lib/cobalt/sched.c
@@ -0,0 +1,390 @@
+/*
+ * Copyright (C) 2005-2015 Philippe Gerum .
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "current.h"
+#include "internal.h"
+
+/**
+ * @ingroup cobalt_api
+ * @defgroup cobalt_api_scheduler Process scheduling
+ *
+ * Cobalt/POSIX process scheduling
+ *
+ * @see
+ * http://pubs.opengroup.org/onlinepubs/95399/functions/xsh_chap02_08.html#tag_02_08_04";>
+ * Specification.
+ *
+ *@{
+ */
+
+/**
+ * Yield the processor.
+ *
+ * This function move the current thread at the end of its priority group.
+ *
+ * @retval 0
+ *
+ * @see
+ * http://www.opengroup.org/onlinepubs/95399/functions/sched_yield.html";>
+ * Specification.
+ *
+ */
+COBALT_IMPL(int, sched_yield, (void))
+{
+   if (cobalt_get_current() == XN_NO_HANDLE ||
+   (cobalt_get_current_mode() & (XNWEAK|XNRELAX)) == (XNWEAK|XNRELAX))
+   return __STD(sched_yield());
+
+   return -XENOMAI_SYSCALL0(sc_cobalt_sched_yield);
+}
+
+/**
+ * Get minimum priority of the specified scheduling policy.
+ *
+ * This service returns the minimum priority of the scheduling policy @a
+ * policy.
+ *
+ * @param policy scheduling policy.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a policy is invalid.
+ *
+ * @see
+ * http://www.opengroup.org/onlinepubs/95399/functions/sched_get_priority_min.html";>
+ * Specification.
+ *
+ */
+COBALT_IMPL(int, sched_get_priority_min, (int policy))
+{
+   int ret;
+
+   switch (policy) {
+   case SCHED_FIFO:
+   case SCHED_RR:
+   break;
+   default:
+   ret = XENOMAI_SYSCALL1(sc_cobalt_sched_minprio, policy);
+   if (ret >= 0)
+   return ret;
+   if (ret != -EINVAL) {
+   errno = -ret;
+   return -1;
+   }
+   }
+
+   return __STD(sched_get_priority_min(policy));
+}
+
+/**
+ * Get extended minimum priority of the specified scheduling policy.
+ *
+ * This service returns the minimum priority of the scheduling policy
+ * @a policy, reflecting any Cobalt extension to the standard classes.
+ *
+ * @param policy scheduling policy.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a policy is invalid.
+ *
+ * @see
+ * http://www.opengroup.org/onlinepubs/95399/functions/sched_get_priority_min.html";>
+ * Specification.
+ *
+ */
+int sched_get_priority_min_ex(int policy)
+{
+   int ret;
+
+   ret = XENOMAI_SYSCALL1(sc_cobalt_sched_minprio, policy);
+   if (ret >= 0)
+   return ret;
+   if (ret != -EINVAL) {
+   errno = -ret;
+   return -1;
+   }
+
+   return __STD(sched_get_priority_min(policy));
+}
+
+/**
+ * Get maximum priority of the specified scheduling policy.
+ *
+ * This service returns the maximum priority of the scheduling policy @a
+ * policy.
+ *
+ * @param policy scheduling policy.
+ *
+ * @retval 0 on success;
+ * @retval -1 with @a errno set if:
+ * - EINVAL, @a policy is invalid.
+