sched.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.
  2. Copyright (C) 1996,1997,1999,2001-2004,2007 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _SCHED_H
  17. #define _SCHED_H 1
  18. #include <features.h>
  19. /* Get type definitions. */
  20. #include <bits/types.h>
  21. #define __need_size_t
  22. #include <stddef.h>
  23. #define __need_timespec
  24. #include <time.h>
  25. /* Get system specific constant and data structure definitions. */
  26. #include <bits/sched.h>
  27. /* Define the real names for the elements of `struct sched_param'. */
  28. #define sched_priority __sched_priority
  29. __BEGIN_DECLS
  30. /* Set scheduling parameters for a process. */
  31. extern int sched_setparam (__pid_t __pid, __const struct sched_param *__param)
  32. __THROW;
  33. /* Retrieve scheduling parameters for a particular process. */
  34. extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __THROW;
  35. /* Set scheduling algorithm and/or parameters for a process. */
  36. extern int sched_setscheduler (__pid_t __pid, int __policy,
  37. __const struct sched_param *__param) __THROW;
  38. /* Retrieve scheduling algorithm for a particular purpose. */
  39. extern int sched_getscheduler (__pid_t __pid) __THROW;
  40. /* Yield the processor. */
  41. extern int sched_yield (void) __THROW;
  42. /* Get maximum priority value for a scheduler. */
  43. extern int sched_get_priority_max (int __algorithm) __THROW;
  44. /* Get minimum priority value for a scheduler. */
  45. extern int sched_get_priority_min (int __algorithm) __THROW;
  46. /* Get the SCHED_RR interval for the named process. */
  47. extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
  48. #if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
  49. /* Access macros for `cpu_set'. */
  50. # define CPU_SETSIZE __CPU_SETSIZE
  51. # define CPU_SET(cpu, cpusetp) __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
  52. # define CPU_CLR(cpu, cpusetp) __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
  53. # define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
  54. cpusetp)
  55. # define CPU_ZERO(cpusetp) __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)
  56. # define CPU_COUNT(cpusetp) __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)
  57. # define CPU_SET_S(cpu, setsize, cpusetp) __CPU_SET_S (cpu, setsize, cpusetp)
  58. # define CPU_CLR_S(cpu, setsize, cpusetp) __CPU_CLR_S (cpu, setsize, cpusetp)
  59. # define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \
  60. cpusetp)
  61. # define CPU_ZERO_S(setsize, cpusetp) __CPU_ZERO_S (setsize, cpusetp)
  62. # define CPU_COUNT_S(setsize, cpusetp) __CPU_COUNT_S (setsize, cpusetp)
  63. # define CPU_EQUAL(cpusetp1, cpusetp2) \
  64. __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
  65. # define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
  66. __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)
  67. # define CPU_AND(destset, srcset1, srcset2) \
  68. __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)
  69. # define CPU_OR(destset, srcset1, srcset2) \
  70. __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
  71. # define CPU_XOR(destset, srcset1, srcset2) \
  72. __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)
  73. # define CPU_AND_S(setsize, destset, srcset1, srcset2) \
  74. __CPU_OP_S (setsize, destset, srcset1, srcset2, &)
  75. # define CPU_OR_S(setsize, destset, srcset1, srcset2) \
  76. __CPU_OP_S (setsize, destset, srcset1, srcset2, |)
  77. # define CPU_XOR_S(setsize, destset, srcset1, srcset2) \
  78. __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)
  79. # define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
  80. # define CPU_ALLOC(count) __CPU_ALLOC (count)
  81. # define CPU_FREE(cpuset) __CPU_FREE (cpuset)
  82. /* Set the CPU affinity for a task */
  83. extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
  84. __const cpu_set_t *__cpuset) __THROW;
  85. /* Get the CPU affinity for a task */
  86. extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
  87. cpu_set_t *__cpuset) __THROW;
  88. #endif
  89. __END_DECLS
  90. #endif /* sched.h */