[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9610 - gnuradio/trunk/gnuradio-core/src/lib/runtime
From: |
eb |
Subject: |
[Commit-gnuradio] r9610 - gnuradio/trunk/gnuradio-core/src/lib/runtime |
Date: |
Fri, 19 Sep 2008 18:16:42 -0600 (MDT) |
Author: eb
Date: 2008-09-19 18:16:41 -0600 (Fri, 19 Sep 2008)
New Revision: 9610
Modified:
gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_realtime.cc
gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_realtime.h
Log:
gr_realtime now uses gruel::enable_realtime_scheduling
Modified: gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_realtime.cc
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_realtime.cc 2008-09-19
23:41:21 UTC (rev 9609)
+++ gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_realtime.cc 2008-09-20
00:16:41 UTC (rev 9610)
@@ -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
Modified: gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_realtime.h
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_realtime.h 2008-09-19
23:41:21 UTC (rev 9609)
+++ gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_realtime.h 2008-09-20
00:16:41 UTC (rev 9610)
@@ -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 */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9610 - gnuradio/trunk/gnuradio-core/src/lib/runtime,
eb <=