summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/runtime
diff options
context:
space:
mode:
authormichaelld2007-09-13 20:36:23 +0000
committermichaelld2007-09-13 20:36:23 +0000
commit6006b92a287fa5a23bcb7905f6f854d9c9dd4462 (patch)
tree24dce7172947148cc34c605e8821ce5985f052f2 /gnuradio-core/src/lib/runtime
parentaecbab9d0720eacfb4e42aeb825c3f821c4df7a3 (diff)
downloadgnuradio-6006b92a287fa5a23bcb7905f6f854d9c9dd4462.tar.gz
gnuradio-6006b92a287fa5a23bcb7905f6f854d9c9dd4462.tar.bz2
gnuradio-6006b92a287fa5a23bcb7905f6f854d9c9dd4462.zip
Made changes, such that:
* trunk now passes "make distcheck" on OSX * verified that 'realtime' scheduling now works on systems with 'pthread_setschedparam' but not 'sched_setscheduler' (e.g. darwin); the latter has priority if both are installed. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@6427 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib/runtime')
-rw-r--r--gnuradio-core/src/lib/runtime/gr_realtime.cc29
1 files changed, 28 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_realtime.cc b/gnuradio-core/src/lib/runtime/gr_realtime.cc
index 878411df2..35d0ef381 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 Free Software Foundation, Inc.
+ * Copyright 2006,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -58,6 +58,33 @@ gr_enable_realtime_scheduling()
return RT_OK;
}
+#elif defined(HAVE_PTHREAD_SETSCHEDPARAM)
+
+#include <pthread.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