sched.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Module: sched.h
  3. *
  4. * Purpose:
  5. * Provides an implementation of POSIX realtime extensions
  6. * as defined in
  7. *
  8. * POSIX 1003.1b-1993 (POSIX.1b)
  9. *
  10. * --------------------------------------------------------------------------
  11. *
  12. * Pthreads-embedded (PTE) - POSIX Threads Library for embedded systems
  13. * Copyright(C) 2008 Jason Schmidlapp
  14. *
  15. * Contact Email: [email protected]
  16. *
  17. *
  18. * Pthreads-embedded (PTE) - POSIX Threads Library for embedded systems
  19. * Copyright(C) 2008 Jason Schmidlapp
  20. *
  21. * Contact Email: [email protected]
  22. *
  23. *
  24. * Based upon Pthreads-win32 - POSIX Threads Library for Win32
  25. * Copyright(C) 1998 John E. Bossom
  26. * Copyright(C) 1999,2005 Pthreads-win32 contributors
  27. *
  28. * Contact Email: [email protected]
  29. *
  30. * The original list of contributors to the Pthreads-win32 project
  31. * is contained in the file CONTRIBUTORS.ptw32 included with the
  32. * source code distribution. The list can also be seen at the
  33. * following World Wide Web location:
  34. * http://sources.redhat.com/pthreads-win32/contributors.html
  35. *
  36. * This library is free software; you can redistribute it and/or
  37. * modify it under the terms of the GNU Lesser General Public
  38. * License as published by the Free Software Foundation; either
  39. * version 2 of the License, or (at your option) any later version.
  40. *
  41. * This library is distributed in the hope that it will be useful,
  42. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  43. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  44. * Lesser General Public License for more details.
  45. *
  46. * You should have received a copy of the GNU Lesser General Public
  47. * License along with this library in the file COPYING.LIB;
  48. * if not, write to the Free Software Foundation, Inc.,
  49. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  50. */
  51. #ifndef _SCHED_H
  52. #define _SCHED_H
  53. #include <pte_types.h>
  54. #undef PTE_LEVEL
  55. #if defined(_POSIX_SOURCE)
  56. #define PTE_LEVEL 0
  57. /* Early POSIX */
  58. #endif
  59. #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
  60. #undef PTE_LEVEL
  61. #define PTE_LEVEL 1
  62. /* Include 1b, 1c and 1d */
  63. #endif
  64. #if defined(INCLUDE_NP)
  65. #undef PTE_LEVEL
  66. #define PTE_LEVEL 2
  67. /* Include Non-Portable extensions */
  68. #endif
  69. #define PTE_LEVEL_MAX 3
  70. #if !defined(PTE_LEVEL)
  71. #define PTE_LEVEL PTE_LEVEL_MAX
  72. /* Include everything */
  73. #endif
  74. /*
  75. *
  76. */
  77. /* Thread scheduling policies */
  78. enum
  79. {
  80. SCHED_OTHER = 0,
  81. SCHED_FIFO,
  82. SCHED_RR,
  83. SCHED_MIN = SCHED_OTHER,
  84. SCHED_MAX = SCHED_RR
  85. };
  86. struct sched_param
  87. {
  88. int sched_priority;
  89. };
  90. #ifdef __cplusplus
  91. extern "C"
  92. {
  93. #endif /* __cplusplus */
  94. int sched_yield (void);
  95. int sched_get_priority_min (int policy);
  96. int sched_get_priority_max (int policy);
  97. int sched_setscheduler (pid_t pid, int policy);
  98. /*
  99. * Note that this macro returns ENOTSUP rather than
  100. * ENOSYS as might be expected. However, returning ENOSYS
  101. * should mean that sched_get_priority_{min,max} are
  102. * not implemented as well as sched_rr_get_interval.
  103. * This is not the case, since we just don't support
  104. * round-robin scheduling. Therefore I have chosen to
  105. * return the same value as sched_setscheduler when
  106. * SCHED_RR is passed to it.
  107. */
  108. #define sched_rr_get_interval(_pid, _interval) \
  109. ( errno = ENOTSUP, (int) -1 )
  110. #ifdef __cplusplus
  111. } /* End of extern "C" */
  112. #endif /* __cplusplus */
  113. #undef PTE_LEVEL
  114. #undef PTE_LEVEL_MAX
  115. #endif /* !_SCHED_H */