diff options
author | eb | 2008-09-20 00:16:41 +0000 |
---|---|---|
committer | eb | 2008-09-20 00:16:41 +0000 |
commit | 8c2e26d9f7ef82fe5ae54a8e2b7744dedd746c2b (patch) | |
tree | 22107c6faf75677d098de821abf6d66e4ddade10 /gnuradio-core | |
parent | cefb4c1872c5e172f30933dcfa6f6b1156765335 (diff) | |
download | gnuradio-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')
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_realtime.cc | 71 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_realtime.h | 12 |
2 files changed, 6 insertions, 77 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(¶m, 0, sizeof(param)); - param.sched_priority = pri; - int result = sched_setscheduler(pid, policy, ¶m); - 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 (¶m, 0, sizeof (param)); - param.sched_priority = pri; - int result = pthread_setschedparam (this_thread, policy, ¶m); - 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 diff --git a/gnuradio-core/src/lib/runtime/gr_realtime.h b/gnuradio-core/src/lib/runtime/gr_realtime.h index cf0423aaa..830c201d7 100644 --- a/gnuradio-core/src/lib/runtime/gr_realtime.h +++ b/gnuradio-core/src/lib/runtime/gr_realtime.h @@ -23,18 +23,14 @@ #ifndef INCLUDED_GR_REALTIME_H #define INCLUDED_GR_REALTIME_H -typedef enum { - RT_OK = 0, - RT_NOT_IMPLEMENTED, - RT_NO_PRIVS, - RT_OTHER_ERROR -} gr_rt_status_t; +#include <gruel/realtime.h> + +typedef gruel::rt_status_t gr_rt_status_t; /*! * \brief If possible, enable high-priority "real time" scheduling. * \ingroup misc */ -gr_rt_status_t -gr_enable_realtime_scheduling(); +gr_rt_status_t gr_enable_realtime_scheduling(); #endif /* INCLUDED_GR_REALTIME_H */ |