3 * Copyright 2006,2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
23 #ifndef INCLUDED_GRUEL_REALTIME_H
24 #define INCLUDED_GRUEL_REALTIME_H
29 * \brief System independent way to ask for realtime scheduling
44 enum rt_sched_policy {
45 RT_SCHED_RR = 0, // round robin
46 RT_SCHED_FIFO = 1, // first in first out
50 * Define the range for our virtual priorities (don't change these)
52 * Processes (or threads) with numerically higher priority values
53 * are scheduled before processes with numerically lower priority
54 * values. Thus, the value returned by rt_priority_max() will be
55 * greater than the value returned by rt_priority_min().
57 static inline int rt_priority_min() { return 0; }
58 static inline int rt_priority_max() { return 15; }
59 static inline int rt_priority_default() { return 1; }
61 struct rt_sched_param {
63 rt_sched_policy policy;
66 : priority(rt_priority_default()), policy(RT_SCHED_RR){}
68 rt_sched_param(int priority_, rt_sched_policy policy_ = RT_SCHED_RR)
70 if (priority_ < rt_priority_min() || priority_ > rt_priority_max())
71 throw std::invalid_argument("rt_sched_param: priority out of range");
79 * \brief If possible, enable "realtime" scheduling.
82 * In general, this means that the code will be scheduled before any
83 * non-realtime (normal) processes. Note that if your code contains
84 * an non-blocking infinite loop and you enable realtime scheduling,
85 * it's possible to hang the system.
88 // NOTE: If you change this, you need to change the code in
89 // gnuradio-core/src/lib/runtime/gr_realtime.i, see note there.
91 enable_realtime_scheduling(rt_sched_param = rt_sched_param());
95 #endif /* INCLUDED_GRUEL_REALTIME_H */