On Tue, Feb 10, 2015 at 16:35:19 +0100, Martin Kletzander wrote:
This function uses sched_setscheduler() function so it works with
processes and threads as well (even threads not created by us, which is
what we'll need in the future).
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
configure.ac | 4 +-
src/libvirt_private.syms | 1 +
src/util/virprocess.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++-
src/util/virprocess.h | 20 ++++++++-
4 files changed, 124 insertions(+), 5 deletions(-)
...
+#if HAVE_SCHED_SETSCHEDULER
+
+static int
+virProcessSchedTranslatePolicy(virProcessSchedPolicy policy)
+{
+ switch (policy) {
+ case VIR_PROC_POLICY_NONE:
+ return SCHED_OTHER;
+
+ case VIR_PROC_POLICY_BATCH:
+ return SCHED_BATCH;
+
+ case VIR_PROC_POLICY_IDLE:
+ return SCHED_IDLE;
+
+ case VIR_PROC_POLICY_FIFO:
+ return SCHED_FIFO;
+
+ case VIR_PROC_POLICY_RR:
+ return SCHED_RR;
+
+ case VIR_PROC_POLICY_LAST:
+ /* nada */
I know I'm late with this comment, but:
I don't think the _LAST case is so obscure that we would need to comment
it with such an insightful comment.
+ break;
+ }
+
+ return -1;
+}
+
Peter