GNU Radio 3.6.1 C++ API
realtime.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2006,2008 Free Software Foundation, Inc.
4
*
5
* This file is part of GNU Radio
6
*
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)
10
* any later version.
11
*
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.
16
*
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.
21
*/
22
23
#ifndef INCLUDED_GRUEL_REALTIME_H
24
#define INCLUDED_GRUEL_REALTIME_H
25
26
#include <
gruel/api.h
>
27
#include <stdexcept>
28
29
/*!
30
* \brief System independent way to ask for realtime scheduling
31
*
32
* \sa sys_pri.h
33
*/
34
35
namespace
gruel {
36
37
typedef
enum
{
38
RT_OK
= 0,
39
RT_NOT_IMPLEMENTED
,
40
RT_NO_PRIVS
,
41
RT_OTHER_ERROR
42
}
rt_status_t
;
43
44
45
enum
rt_sched_policy
{
46
RT_SCHED_RR
= 0,
// round robin
47
RT_SCHED_FIFO
= 1,
// first in first out
48
};
49
50
/*
51
* Define the range for our virtual priorities (don't change these)
52
*
53
* Processes (or threads) with numerically higher priority values
54
* are scheduled before processes with numerically lower priority
55
* values. Thus, the value returned by rt_priority_max() will be
56
* greater than the value returned by rt_priority_min().
57
*/
58
static
inline
int
rt_priority_min
() {
return
0; }
59
static
inline
int
rt_priority_max
() {
return
15; }
60
static
inline
int
rt_priority_default
() {
return
1; }
61
62
struct
GRUEL_API
rt_sched_param
{
63
int
priority
;
64
rt_sched_policy
policy
;
65
66
rt_sched_param
()
67
: priority(
rt_priority_default
()), policy(
RT_SCHED_RR
){}
68
69
rt_sched_param
(
int
priority_,
rt_sched_policy
policy_ =
RT_SCHED_RR
)
70
{
71
if
(priority_ <
rt_priority_min
() || priority_ >
rt_priority_max
())
72
throw
std::invalid_argument(
"rt_sched_param: priority out of range"
);
73
74
priority = priority_;
75
policy = policy_;
76
}
77
};
78
79
/*!
80
* \brief If possible, enable "realtime" scheduling.
81
* \ingroup misc
82
*
83
* In general, this means that the code will be scheduled before any
84
* non-realtime (normal) processes. Note that if your code contains
85
* an non-blocking infinite loop and you enable realtime scheduling,
86
* it's possible to hang the system.
87
*/
88
89
// NOTE: If you change this, you need to change the code in
90
// gnuradio-core/src/lib/runtime/gr_realtime.i, see note there.
91
rt_status_t
92
GRUEL_API
enable_realtime_scheduling
(rt_sched_param = rt_sched_param());
93
94
}
// namespace gruel
95
96
#endif
/* INCLUDED_GRUEL_REALTIME_H */
gruel
src
include
gruel
realtime.h
Generated on Mon Aug 6 2012 11:12:54 for GNU Radio 3.6.1 C++ API by
1.8.1.2