sched.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef _SCHED_H
  16. #define _SCHED_H 1
  17. #include <features.h>
  18. /* Get type definitions. */
  19. #include <bits/types.h>
  20. #define __need_size_t
  21. #include <stddef.h>
  22. #define __need_timespec
  23. #include <time.h>
  24. /* Get system specific constant and data structure definitions. */
  25. #include <bits/sched.h>
  26. /* Define the real names for the elements of `struct sched_param'. */
  27. #define sched_priority __sched_priority
  28. __BEGIN_DECLS
  29. /* Set scheduling parameters for a process. */
  30. extern int sched_setparam (__pid_t __pid, const struct sched_param *__param)
  31. __THROW;
  32. /* Retrieve scheduling parameters for a particular process. */
  33. extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __THROW;
  34. /* Set scheduling algorithm and/or parameters for a process. */
  35. extern int sched_setscheduler (__pid_t __pid, int __policy,
  36. const struct sched_param *__param) __THROW;
  37. /* Retrieve scheduling algorithm for a particular purpose. */
  38. extern int sched_getscheduler (__pid_t __pid) __THROW;
  39. /* Yield the processor. */
  40. extern int sched_yield (void) __THROW;
  41. /* Get maximum priority value for a scheduler. */
  42. extern int sched_get_priority_max (int __algorithm) __THROW;
  43. /* Get minimum priority value for a scheduler. */
  44. extern int sched_get_priority_min (int __algorithm) __THROW;
  45. /* Get the SCHED_RR interval for the named process. */
  46. extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
  47. #if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
  48. /* Access macros for `cpu_set'. */
  49. # define CPU_SETSIZE __CPU_SETSIZE
  50. # define CPU_SET(cpu, cpusetp) __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
  51. # define CPU_CLR(cpu, cpusetp) __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
  52. # define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
  53. cpusetp)
  54. # define CPU_ZERO(cpusetp) __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)
  55. # define CPU_COUNT(cpusetp) __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)
  56. # define CPU_SET_S(cpu, setsize, cpusetp) __CPU_SET_S (cpu, setsize, cpusetp)
  57. # define CPU_CLR_S(cpu, setsize, cpusetp) __CPU_CLR_S (cpu, setsize, cpusetp)
  58. # define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \
  59. cpusetp)
  60. # define CPU_ZERO_S(setsize, cpusetp) __CPU_ZERO_S (setsize, cpusetp)
  61. # define CPU_COUNT_S(setsize, cpusetp) __CPU_COUNT_S (setsize, cpusetp)
  62. # define CPU_EQUAL(cpusetp1, cpusetp2) \
  63. __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
  64. # define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
  65. __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)
  66. # define CPU_AND(destset, srcset1, srcset2) \
  67. __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)
  68. # define CPU_OR(destset, srcset1, srcset2) \
  69. __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
  70. # define CPU_XOR(destset, srcset1, srcset2) \
  71. __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)
  72. # define CPU_AND_S(setsize, destset, srcset1, srcset2) \
  73. __CPU_OP_S (setsize, destset, srcset1, srcset2, &)
  74. # define CPU_OR_S(setsize, destset, srcset1, srcset2) \
  75. __CPU_OP_S (setsize, destset, srcset1, srcset2, |)
  76. # define CPU_XOR_S(setsize, destset, srcset1, srcset2) \
  77. __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)
  78. # define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
  79. # define CPU_ALLOC(count) __CPU_ALLOC (count)
  80. # define CPU_FREE(cpuset) __CPU_FREE (cpuset)
  81. /* Set the CPU affinity for a task */
  82. extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
  83. const cpu_set_t *__cpuset) __THROW;
  84. /* Get the CPU affinity for a task */
  85. extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
  86. cpu_set_t *__cpuset) __THROW;
  87. # ifdef _LIBC
  88. extern int __clone (int (*__fn) (void *__arg), void *__child_stack,
  89. int __flags, void *__arg, ...);
  90. extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
  91. size_t __child_stack_size, int __flags, void *__arg, ...);
  92. # endif
  93. #endif
  94. __END_DECLS
  95. #endif /* sched.h */