3 * Simple way to get your program running at high priority
4 * with realtime schedulling.
6 * Copyright (c) 2012 Gordon Henderson
7 ***********************************************************************
8 * This file is part of wiringPi:
9 * https://projects.drogon.net/raspberry-pi/wiringpi/
11 * wiringPi is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as
13 * published by the Free Software Foundation, either version 3 of the
14 * License, or (at your option) any later version.
16 * wiringPi is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with wiringPi.
23 * If not, see <http://www.gnu.org/licenses/>.
24 ***********************************************************************
35 * Attempt to set a high priority schedulling for the running program
36 *********************************************************************************
39 int piHiPri (const int pri)
41 struct sched_param sched ;
43 memset (&sched, 0, sizeof(sched)) ;
45 if (pri > sched_get_priority_max (SCHED_RR))
46 sched.sched_priority = sched_get_priority_max (SCHED_RR) ;
48 sched.sched_priority = pri ;
50 return sched_setscheduler (0, SCHED_RR, &sched) ;