You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 jaren geleden
12 jaren geleden
12 jaren geleden
12 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * piHiPri:
  3. * Simple way to get your program running at high priority
  4. * with realtime schedulling.
  5. *
  6. * Copyright (c) 2012 Gordon Henderson
  7. ***********************************************************************
  8. * This file is part of wiringPi:
  9. * https://github.com/WiringPi/WiringPi/
  10. *
  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.
  15. *
  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.
  20. *
  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. ***********************************************************************
  25. */
  26. #include <sched.h>
  27. #include <string.h>
  28. #include "wiringPi.h"
  29. /*
  30. * piHiPri:
  31. * Attempt to set a high priority schedulling for the running program
  32. *********************************************************************************
  33. */
  34. int piHiPri (const int pri)
  35. {
  36. struct sched_param sched ;
  37. memset (&sched, 0, sizeof(sched)) ;
  38. if (pri > sched_get_priority_max (SCHED_RR))
  39. sched.sched_priority = sched_get_priority_max (SCHED_RR) ;
  40. else
  41. sched.sched_priority = pri ;
  42. return sched_setscheduler (0, SCHED_RR, &sched) ;
  43. }