commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8642 - in gnuradio/trunk: . config gruel gruel/src gr


From: jcorgan
Subject: [Commit-gnuradio] r8642 - in gnuradio/trunk: . config gruel gruel/src gruel/src/include gruel/src/include/gruel gruel/src/lib
Date: Fri, 20 Jun 2008 12:14:50 -0600 (MDT)

Author: jcorgan
Date: 2008-06-20 12:14:47 -0600 (Fri, 20 Jun 2008)
New Revision: 8642

Added:
   gnuradio/trunk/config/grc_gruel.m4
   gnuradio/trunk/gruel/
   gnuradio/trunk/gruel/AUTHORS
   gnuradio/trunk/gruel/ChangeLog
   gnuradio/trunk/gruel/Makefile.am
   gnuradio/trunk/gruel/README
   gnuradio/trunk/gruel/doc/
   gnuradio/trunk/gruel/gruel.pc.in
   gnuradio/trunk/gruel/src/
   gnuradio/trunk/gruel/src/Makefile.am
   gnuradio/trunk/gruel/src/include/
   gnuradio/trunk/gruel/src/include/Makefile.am
   gnuradio/trunk/gruel/src/include/gruel/
   gnuradio/trunk/gruel/src/include/gruel/Makefile.am
   gnuradio/trunk/gruel/src/include/gruel/realtime.h
   gnuradio/trunk/gruel/src/lib/
   gnuradio/trunk/gruel/src/lib/Makefile.am
   gnuradio/trunk/gruel/src/lib/realtime.cc
Removed:
   gnuradio/trunk/gruel/AUTHORS
   gnuradio/trunk/gruel/ChangeLog
   gnuradio/trunk/gruel/Makefile.am
   gnuradio/trunk/gruel/README
   gnuradio/trunk/gruel/doc/
   gnuradio/trunk/gruel/gruel.pc.in
   gnuradio/trunk/gruel/src/
   gnuradio/trunk/gruel/src/Makefile.am
   gnuradio/trunk/gruel/src/include/
   gnuradio/trunk/gruel/src/include/Makefile.am
   gnuradio/trunk/gruel/src/include/gruel/
   gnuradio/trunk/gruel/src/include/gruel/Makefile.am
   gnuradio/trunk/gruel/src/include/gruel/realtime.h
   gnuradio/trunk/gruel/src/lib/
   gnuradio/trunk/gruel/src/lib/Makefile.am
   gnuradio/trunk/gruel/src/lib/realtime.cc
Modified:
   gnuradio/trunk/Makefile.common
   gnuradio/trunk/config/Makefile.am
   gnuradio/trunk/configure.ac
Log:
Merged -r8639:8641 from jcorgan/gruel into trunk.  Adds libgruel, the GNU Radio 
Utility Etcetera Library.  See README for description.

Modified: gnuradio/trunk/Makefile.common
===================================================================
--- gnuradio/trunk/Makefile.common      2008-06-20 18:08:32 UTC (rev 8641)
+++ gnuradio/trunk/Makefile.common      2008-06-20 18:14:47 UTC (rev 8642)
@@ -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/trunk/config/Makefile.am
===================================================================
--- gnuradio/trunk/config/Makefile.am   2008-06-20 18:08:32 UTC (rev 8641)
+++ gnuradio/trunk/config/Makefile.am   2008-06-20 18:14:47 UTC (rev 8642)
@@ -53,6 +53,7 @@
        grc_gr_video_sdl.m4 \
        grc_gr_wxgui.m4 \
        grc_mblock.m4 \
+       grc_gruel.m4 \
        gr_check_createfilemapping.m4 \
        gr_check_mc4020.m4 \
        gr_check_shm_open.m4 \

Copied: gnuradio/trunk/config/grc_gruel.m4 (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/config/grc_gruel.m4)
===================================================================
--- gnuradio/trunk/config/grc_gruel.m4                          (rev 0)
+++ gnuradio/trunk/config/grc_gruel.m4  2008-06-20 18:14:47 UTC (rev 8642)
@@ -0,0 +1,44 @@
+dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc.
+dnl 
+dnl This file is part of GNU Radio
+dnl 
+dnl GNU Radio is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3, or (at your option)
+dnl any later version.
+dnl 
+dnl GNU Radio is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with GNU Radio; see the file COPYING.  If not, write to
+dnl the Free Software Foundation, Inc., 51 Franklin Street,
+dnl Boston, MA 02110-1301, USA.
+
+AC_DEFUN([GRC_GRUEL],[
+    GRC_ENABLE(gruel)
+    GRC_WITH(gruel)
+
+    dnl If execution gets to here, $passed will be:
+    dnl   with : if the --with code didn't error out
+    dnl   yes  : if the --enable code passed muster and all dependencies are 
met
+    dnl   no   : otherwise
+    if test $passed != with; then
+       dnl how and where to find INCLUDES and LA
+       gruel_INCLUDES="-I\${abs_top_srcdir}/gruel/src/include"
+        gruel_LA="\${abs_top_builddir}/gruel/src/lib/libgruel.la"
+    fi
+
+    AC_CONFIG_FILES([\
+        gruel/Makefile \
+        gruel/gruel.pc \
+        gruel/src/Makefile \
+        gruel/src/include/Makefile \
+        gruel/src/include/gruel/Makefile \
+        gruel/src/lib/Makefile \
+    ])
+
+    GRC_BUILD_CONDITIONAL(gruel,[])
+])

Modified: gnuradio/trunk/configure.ac
===================================================================
--- gnuradio/trunk/configure.ac 2008-06-20 18:08:32 UTC (rev 8641)
+++ gnuradio/trunk/configure.ac 2008-06-20 18:14:47 UTC (rev 8642)
@@ -239,6 +239,7 @@
 )
 
 build_dirs="config"
+GRC_GRUEL                       dnl must come first
 GRC_OMNITHREAD                 dnl must come before gnuradio-core and mblock
 GRC_GCELL
 GRC_GNURADIO_CORE

Copied: gnuradio/trunk/gruel (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel)


Property changes on: gnuradio/trunk/gruel
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in
gruel.pc


Deleted: gnuradio/trunk/gruel/AUTHORS

Copied: gnuradio/trunk/gruel/AUTHORS (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/AUTHORS)
===================================================================
--- gnuradio/trunk/gruel/AUTHORS                                (rev 0)
+++ gnuradio/trunk/gruel/AUTHORS        2008-06-20 18:14:47 UTC (rev 8642)
@@ -0,0 +1 @@
+Johnathan Corgan <address@hidden>

Deleted: gnuradio/trunk/gruel/ChangeLog

Copied: gnuradio/trunk/gruel/ChangeLog (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/ChangeLog)
===================================================================
--- gnuradio/trunk/gruel/ChangeLog                              (rev 0)
+++ gnuradio/trunk/gruel/ChangeLog      2008-06-20 18:14:47 UTC (rev 8642)
@@ -0,0 +1,20 @@
+#
+# Copyright 2008 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.
+# 

Deleted: gnuradio/trunk/gruel/Makefile.am

Copied: gnuradio/trunk/gruel/Makefile.am (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/Makefile.am)
===================================================================
--- gnuradio/trunk/gruel/Makefile.am                            (rev 0)
+++ gnuradio/trunk/gruel/Makefile.am    2008-06-20 18:14:47 UTC (rev 8642)
@@ -0,0 +1,30 @@
+#
+# Copyright 2008 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.
+# 
+
+include $(top_srcdir)/Makefile.common
+
+EXTRA_DIST = \
+    gruel.pc.in
+
+SUBDIRS = src
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = gruel.pc

Deleted: gnuradio/trunk/gruel/README

Copied: gnuradio/trunk/gruel/README (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/README)
===================================================================
--- gnuradio/trunk/gruel/README                         (rev 0)
+++ gnuradio/trunk/gruel/README 2008-06-20 18:14:47 UTC (rev 8642)
@@ -0,0 +1,30 @@
+#
+# Copyright 2008 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.
+# 
+
+The GNU Radio Utility Etcetera Library, a collection of low-level routines
+to avoid dependencies on the full GNU Radio core or other libraries.
+
+Over time, some code from libgnuradio-core, libpmt, libmblock, libusrp,
+and libusrp2 will migrate here, to avoid duplication of code and simplify
+dependencies.
+
+By design, this library will not have dependencies on any other part
+of GNU Radio, but may have external dependencies such as Boost.

Copied: gnuradio/trunk/gruel/doc (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/doc)

Deleted: gnuradio/trunk/gruel/gruel.pc.in

Copied: gnuradio/trunk/gruel/gruel.pc.in (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/gruel.pc.in)
===================================================================
--- gnuradio/trunk/gruel/gruel.pc.in                            (rev 0)
+++ gnuradio/trunk/gruel/gruel.pc.in    2008-06-20 18:14:47 UTC (rev 8642)
@@ -0,0 +1,11 @@
address@hidden@
address@hidden@
address@hidden@
address@hidden@
+
+Name: gruel
+Description: The GNU Radio Utility Etcetera Library
+Requires: 
+Version: @VERSION@
+Libs: -L${libdir} -lgruel
+Cflags: -I${includedir}

Copied: gnuradio/trunk/gruel/src (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/src)


Property changes on: gnuradio/trunk/gruel/src
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in


Deleted: gnuradio/trunk/gruel/src/Makefile.am

Copied: gnuradio/trunk/gruel/src/Makefile.am (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/Makefile.am)
===================================================================
--- gnuradio/trunk/gruel/src/Makefile.am                                (rev 0)
+++ gnuradio/trunk/gruel/src/Makefile.am        2008-06-20 18:14:47 UTC (rev 
8642)
@@ -0,0 +1,22 @@
+#
+# Copyright 2008 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.
+# 
+
+SUBDIRS = include lib

Copied: gnuradio/trunk/gruel/src/include (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include)


Property changes on: gnuradio/trunk/gruel/src/include
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in


Deleted: gnuradio/trunk/gruel/src/include/Makefile.am

Copied: gnuradio/trunk/gruel/src/include/Makefile.am (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/Makefile.am)
===================================================================
--- gnuradio/trunk/gruel/src/include/Makefile.am                                
(rev 0)
+++ gnuradio/trunk/gruel/src/include/Makefile.am        2008-06-20 18:14:47 UTC 
(rev 8642)
@@ -0,0 +1,22 @@
+#
+# Copyright 2008 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.
+# 
+
+SUBDIRS = gruel

Copied: gnuradio/trunk/gruel/src/include/gruel (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/gruel)


Property changes on: gnuradio/trunk/gruel/src/include/gruel
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in


Deleted: gnuradio/trunk/gruel/src/include/gruel/Makefile.am

Copied: gnuradio/trunk/gruel/src/include/gruel/Makefile.am (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/gruel/Makefile.am)
===================================================================
--- gnuradio/trunk/gruel/src/include/gruel/Makefile.am                          
(rev 0)
+++ gnuradio/trunk/gruel/src/include/gruel/Makefile.am  2008-06-20 18:14:47 UTC 
(rev 8642)
@@ -0,0 +1,27 @@
+#
+# Copyright 2008 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.
+# 
+
+include $(top_srcdir)/Makefile.common
+
+gruelincludedir = $(prefix)/include/gruel
+
+gruelinclude_HEADERS = \
+       realtime.h

Deleted: gnuradio/trunk/gruel/src/include/gruel/realtime.h

Copied: gnuradio/trunk/gruel/src/include/gruel/realtime.h (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/include/gruel/realtime.h)
===================================================================
--- gnuradio/trunk/gruel/src/include/gruel/realtime.h                           
(rev 0)
+++ gnuradio/trunk/gruel/src/include/gruel/realtime.h   2008-06-20 18:14:47 UTC 
(rev 8642)
@@ -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 */

Copied: gnuradio/trunk/gruel/src/lib (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib)


Property changes on: gnuradio/trunk/gruel/src/lib
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in
.libs
.deps


Deleted: gnuradio/trunk/gruel/src/lib/Makefile.am

Copied: gnuradio/trunk/gruel/src/lib/Makefile.am (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib/Makefile.am)
===================================================================
--- gnuradio/trunk/gruel/src/lib/Makefile.am                            (rev 0)
+++ gnuradio/trunk/gruel/src/lib/Makefile.am    2008-06-20 18:14:47 UTC (rev 
8642)
@@ -0,0 +1,39 @@
+#
+# Copyright 2008 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.
+# 
+
+include $(top_srcdir)/Makefile.common
+
+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 = \
+       realtime.cc
+
+# magic flags
+libgruel_la_LDFLAGS = $(NO_UNDEFINED)
+
+# link the library against the c++ standard library
+libgruel_la_LIBADD = \
+       -lstdc++                        
+
+noinst_HEADERS =

Deleted: gnuradio/trunk/gruel/src/lib/realtime.cc

Copied: gnuradio/trunk/gruel/src/lib/realtime.cc (from rev 8641, 
gnuradio/branches/developers/jcorgan/gruel/gruel/src/lib/realtime.cc)
===================================================================
--- gnuradio/trunk/gruel/src/lib/realtime.cc                            (rev 0)
+++ gnuradio/trunk/gruel/src/lib/realtime.cc    2008-06-20 18:14:47 UTC (rev 
8642)
@@ -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]