3 * Copyright 2006 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 2, 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.
26 #include <gr_realtime.h>
36 #if defined(HAVE_SCHED_SETSCHEDULER)
39 gr_enable_realtime_scheduling()
41 int policy = SCHED_FIFO;
42 int pri = (sched_get_priority_max (policy) - sched_get_priority_min (policy)) / 2;
43 int pid = 0; // this process
45 struct sched_param param;
46 memset(¶m, 0, sizeof(param));
47 param.sched_priority = pri;
48 int result = sched_setscheduler(pid, policy, ¶m);
53 perror ("sched_setscheduler: failed to set real time priority");
54 return RT_OTHER_ERROR;
57 //printf("SCHED_FIFO enabled with priority = %d\n", pri);
61 // #elif // could try negative niceness
66 gr_enable_realtime_scheduling()
68 return RT_NOT_IMPLEMENTED;