commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r8641 - in gnuradio/branches/developers/jcorgan/gruel:


From: jcorgan
Subject: [Commit-gnuradio] r8641 - in gnuradio/branches/developers/jcorgan/gruel: . gruel gruel/src/include/gruel gruel/src/lib
Date: Fri, 20 Jun 2008 12:08:32 -0600 (MDT)

Author: jcorgan
Date: 2008-06-20 12:08:32 -0600 (Fri, 20 Jun 2008)
New Revision: 8641

Added:
   gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/gruel/realtime.h
   gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib/realtime.cc
Modified:
   gnuradio/branches/developers/jcorgan/gruel/Makefile.common
   gnuradio/branches/developers/jcorgan/gruel/gruel/Makefile.am
   gnuradio/branches/developers/jcorgan/gruel/gruel/gruel.pc.in
   
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/gruel/Makefile.am
   gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib/
   gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib/Makefile.am
Log:
Added gruel::enable_realtime_scheduling()

Modified: gnuradio/branches/developers/jcorgan/gruel/Makefile.common
===================================================================
--- gnuradio/branches/developers/jcorgan/gruel/Makefile.common  2008-06-20 
16:44:58 UTC (rev 8640)
+++ gnuradio/branches/developers/jcorgan/gruel/Makefile.common  2008-06-20 
18:08:32 UTC (rev 8641)
@@ -73,6 +73,10 @@
 GNURADIO_I = @gnuradio_core_I@
 
 # How to link in the USRP library from inside the tree
+GRUEL_INCLUDES = @gruel_INCLUDES@
+GRUEL_LA = @gruel_LA@
+
+# How to link in the USRP library from inside the tree
 USRP_INCLUDES = @usrp_INCLUDES@
 USRP_LA = @usrp_LA@
 

Modified: gnuradio/branches/developers/jcorgan/gruel/gruel/Makefile.am
===================================================================
--- gnuradio/branches/developers/jcorgan/gruel/gruel/Makefile.am        
2008-06-20 16:44:58 UTC (rev 8640)
+++ gnuradio/branches/developers/jcorgan/gruel/gruel/Makefile.am        
2008-06-20 18:08:32 UTC (rev 8641)
@@ -25,7 +25,6 @@
     gruel.pc.in
 
 SUBDIRS = src
-DIST_SUBDIRS = src doc
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = gruel.pc

Modified: gnuradio/branches/developers/jcorgan/gruel/gruel/gruel.pc.in
===================================================================
--- gnuradio/branches/developers/jcorgan/gruel/gruel/gruel.pc.in        
2008-06-20 16:44:58 UTC (rev 8640)
+++ gnuradio/branches/developers/jcorgan/gruel/gruel/gruel.pc.in        
2008-06-20 18:08:32 UTC (rev 8641)
@@ -7,5 +7,5 @@
 Description: The GNU Radio Utility Etcetera Library
 Requires: 
 Version: @VERSION@
-Libs: -L${libdir}
+Libs: -L${libdir} -lgruel
 Cflags: -I${includedir}

Modified: 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/gruel/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/gruel/Makefile.am  
    2008-06-20 16:44:58 UTC (rev 8640)
+++ 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/gruel/Makefile.am  
    2008-06-20 18:08:32 UTC (rev 8641)
@@ -23,4 +23,5 @@
 
 gruelincludedir = $(prefix)/include/gruel
 
-gruelinclude_HEADERS =
+gruelinclude_HEADERS = \
+       realtime.h

Copied: 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/gruel/realtime.h 
(from rev 8625, gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_realtime.h)
===================================================================
--- 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/gruel/realtime.h   
                            (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/gruel/realtime.h   
    2008-06-20 18:08:32 UTC (rev 8641)
@@ -0,0 +1,44 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_REALTIME_H
+#define INCLUDED_REALTIME_H
+
+namespace gruel {
+
+  typedef enum {
+    RT_OK = 0,
+    RT_NOT_IMPLEMENTED,
+    RT_NO_PRIVS,
+    RT_OTHER_ERROR
+  } rt_status_t;
+
+  /*!
+   * \brief If possible, enable high-priority "real time" scheduling.
+   * \ingroup misc
+   */
+  rt_status_t
+  enable_realtime_scheduling();
+
+} // namespace gruel
+
+#endif /* INCLUDED_GR_REALTIME_H */


Property changes on: gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib
___________________________________________________________________
Name: svn:ignore
   - Makefile
Makefile.in
.libs

   + Makefile
Makefile.in
.libs
.deps


Modified: gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib/Makefile.am        
2008-06-20 16:44:58 UTC (rev 8640)
+++ gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib/Makefile.am        
2008-06-20 18:08:32 UTC (rev 8641)
@@ -21,12 +21,13 @@
 
 include $(top_srcdir)/Makefile.common
 
-AM_CPPFLAGS = $(DEFINES) $(BOOST_CFLAGS) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES)
+AM_CPPFLAGS = $(DEFINES) $(BOOST_CFLAGS) $(GRUEL_INCLUDES) $(WITH_INCLUDES)
 
 lib_LTLIBRARIES = libgruel.la
 
 # These are the source files that go into the gruel shared library
-libgruel_la_SOURCES =
+libgruel_la_SOURCES = \
+       realtime.cc
 
 # magic flags
 libgruel_la_LDFLAGS = $(NO_UNDEFINED)

Copied: gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib/realtime.cc 
(from rev 8625, gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_realtime.cc)
===================================================================
--- gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib/realtime.cc        
                        (rev 0)
+++ gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib/realtime.cc        
2008-06-20 18:08:32 UTC (rev 8641)
@@ -0,0 +1,112 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gruel/realtime.h>
+
+#ifdef HAVE_SCHED_H
+#include <sched.h>
+#endif
+
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+
+#if defined(HAVE_SCHED_SETSCHEDULER)
+
+namespace gruel {
+
+  rt_status_t
+  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;
+  }
+
+} // namespace gruel
+
+#elif defined(HAVE_PTHREAD_SETSCHEDPARAM)
+
+#include <pthread.h>
+#include <stdio.h>
+
+namespace gruel {
+
+  rt_status_t
+  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;
+  }
+} // namespace gruel
+
+// #elif // could try negative niceness
+
+#else
+
+namespace gruel {
+
+  rt_status_t
+  enable_realtime_scheduling()
+  {
+    return RT_NOT_IMPLEMENTED;
+  }
+} // namespace gruel
+
+#endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]