Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / lib / runtime / gr_realtime.cc
index 878411df296bb1291dcc3baf8f8a242c5af5df5f..b44c4d408cd280c0c4b8a43f7b70b7e60ad53a5a 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2007,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
 #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;
-}
-
-// #elif // could try negative niceness
-
-#else
-
 gr_rt_status_t
 gr_enable_realtime_scheduling()
 {
-  return RT_NOT_IMPLEMENTED;
+  return gruel::enable_realtime_scheduling();
 }
-
-#endif