summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/runtime/gr_realtime.cc
diff options
context:
space:
mode:
authoreb2008-09-20 00:16:41 +0000
committereb2008-09-20 00:16:41 +0000
commit8c2e26d9f7ef82fe5ae54a8e2b7744dedd746c2b (patch)
tree22107c6faf75677d098de821abf6d66e4ddade10 /gnuradio-core/src/lib/runtime/gr_realtime.cc
parentcefb4c1872c5e172f30933dcfa6f6b1156765335 (diff)
downloadgnuradio-8c2e26d9f7ef82fe5ae54a8e2b7744dedd746c2b.tar.gz
gnuradio-8c2e26d9f7ef82fe5ae54a8e2b7744dedd746c2b.tar.bz2
gnuradio-8c2e26d9f7ef82fe5ae54a8e2b7744dedd746c2b.zip
gr_realtime now uses gruel::enable_realtime_scheduling
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9610 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib/runtime/gr_realtime.cc')
-rw-r--r--gnuradio-core/src/lib/runtime/gr_realtime.cc71
1 files changed, 2 insertions, 69 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_realtime.cc b/gnuradio-core/src/lib/runtime/gr_realtime.cc
index d3cda0eaa..b44c4d408 100644
--- a/gnuradio-core/src/lib/runtime/gr_realtime.cc
+++ b/gnuradio-core/src/lib/runtime/gr_realtime.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2007 Free Software Foundation, Inc.
+ * Copyright 2006,2007,2008 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -25,75 +25,8 @@
#endif
#include <gr_realtime.h>
-#ifdef HAVE_SCHED_H
-#include <sched.h>
-#endif
-
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-
-#if defined(HAVE_SCHED_SETSCHEDULER)
-
gr_rt_status_t
gr_enable_realtime_scheduling()
{
- int policy = SCHED_FIFO;
- int pri = (sched_get_priority_max (policy) + sched_get_priority_min (policy)) / 2;
- int pid = 0; // this process
-
- struct sched_param param;
- memset(&param, 0, sizeof(param));
- param.sched_priority = pri;
- int result = sched_setscheduler(pid, policy, &param);
- if (result != 0){
- if (errno == EPERM)
- return RT_NO_PRIVS;
- else {
- perror ("sched_setscheduler: failed to set real time priority");
- return RT_OTHER_ERROR;
- }
- }
- //printf("SCHED_FIFO enabled with priority = %d\n", pri);
- return RT_OK;
+ return gruel::enable_realtime_scheduling();
}
-
-#elif defined(HAVE_PTHREAD_SETSCHEDPARAM)
-
-#include <pthread.h>
-#include <stdio.h>
-
-gr_rt_status_t
-gr_enable_realtime_scheduling()
-{
- int policy = SCHED_FIFO;
- int pri = (sched_get_priority_max (policy) +
- sched_get_priority_min (policy)) / 2;
- pthread_t this_thread = pthread_self (); // this process
- struct sched_param param;
- memset (&param, 0, sizeof (param));
- param.sched_priority = pri;
- int result = pthread_setschedparam (this_thread, policy, &param);
- if (result != 0) {
- if (errno == EPERM)
- return RT_NO_PRIVS;
- else {
- perror ("pthread_setschedparam: failed to set real time priority");
- return RT_OTHER_ERROR;
- }
- }
- //printf("SCHED_FIFO enabled with priority = %d\n", pri);
- return RT_OK;
-}
-
-// #elif // could try negative niceness
-
-#else
-
-gr_rt_status_t
-gr_enable_realtime_scheduling()
-{
- return RT_NOT_IMPLEMENTED;
-}
-
-#endif