JACK tools
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.

78 lines
2.0KB

  1. // ----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2012 Fons Adriaensen <fons@linuxaudio.org>
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. //
  18. // ----------------------------------------------------------------------------
  19. #include "pxthread.h"
  20. Pxthread::Pxthread (void) : _thrid (0)
  21. {
  22. }
  23. Pxthread::~Pxthread (void)
  24. {
  25. }
  26. extern "C" void *Pxthread_entry_point (void *arg)
  27. {
  28. Pxthread *T = (Pxthread *) arg;
  29. T->thr_main ();
  30. return NULL;
  31. }
  32. int Pxthread::thr_start (int policy, int priority, size_t stacksize)
  33. {
  34. int min, max, rc;
  35. pthread_attr_t attr;
  36. struct sched_param parm;
  37. min = sched_get_priority_min (policy);
  38. max = sched_get_priority_max (policy);
  39. if (priority > max) priority = max;
  40. if (priority < min) priority = min;
  41. parm.sched_priority = priority;
  42. pthread_attr_init (&attr);
  43. pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
  44. pthread_attr_setschedpolicy (&attr, policy);
  45. pthread_attr_setschedparam (&attr, &parm);
  46. pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
  47. pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED);
  48. pthread_attr_setstacksize (&attr, stacksize);
  49. _thrid = 0;
  50. rc = pthread_create (&_thrid,
  51. &attr,
  52. Pxthread_entry_point,
  53. this);
  54. pthread_attr_destroy (&attr);
  55. return rc;
  56. }
  57. void Pxthread::thr_main (void)
  58. {
  59. }