sched.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* Definitions of constants and data structure for POSIX 1003.1b-1993
  2. scheduling interface.
  3. Copyright (C) 1996-1999,2001-2003,2005,2006 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #ifndef __need_schedparam
  18. #ifndef _SCHED_H
  19. # error "Never include <bits/sched.h> directly; use <sched.h> instead."
  20. #endif
  21. /* Scheduling algorithms. */
  22. #define SCHED_OTHER 0
  23. #define SCHED_FIFO 1
  24. #define SCHED_RR 2
  25. #if 0 /*def __USE_GNU*/
  26. # define SCHED_BATCH 3
  27. #endif
  28. #ifdef __USE_MISC
  29. /* Cloning flags. */
  30. # define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */
  31. # define CLONE_VM 0x00000100 /* Set if VM shared between processes. */
  32. # define CLONE_FS 0x00000200 /* Set if fs info shared between processes. */
  33. # define CLONE_FILES 0x00000400 /* Set if open files shared between processes. */
  34. # define CLONE_SIGHAND 0x00000800 /* Set if signal handlers shared. */
  35. # define CLONE_PTRACE 0x00002000 /* Set if tracing continues on the child. */
  36. # define CLONE_VFORK 0x00004000 /* Set if the parent wants the child to
  37. wake it up on mm_release. */
  38. # define CLONE_PARENT 0x00008000 /* Set if we want to have the same
  39. parent as the cloner. */
  40. # define CLONE_THREAD 0x00010000 /* Set to add to same thread group. */
  41. #if 0
  42. # define CLONE_NEWNS 0x00020000 /* Set to create new namespace. */
  43. # define CLONE_SYSVSEM 0x00040000 /* Set to shared SVID SEM_UNDO semantics. */
  44. # define CLONE_SETTLS 0x00080000 /* Set TLS info. */
  45. # define CLONE_PARENT_SETTID 0x00100000 /* Store TID in userlevel buffer
  46. before MM copy. */
  47. # define CLONE_CHILD_CLEARTID 0x00200000 /* Register exit futex and memory
  48. location to clear. */
  49. # define CLONE_DETACHED 0x00400000 /* Create clone detached. */
  50. # define CLONE_UNTRACED 0x00800000 /* Set if the tracing process can't
  51. force CLONE_PTRACE on this clone. */
  52. # define CLONE_CHILD_SETTID 0x01000000 /* Store TID in userlevel buffer in
  53. the child. */
  54. # define CLONE_STOPPED 0x02000000 /* Start in stopped state. */
  55. #endif
  56. #endif
  57. #ifndef __ASSEMBLER__
  58. /* The official definition. */
  59. struct sched_param
  60. {
  61. int __sched_priority;
  62. };
  63. __BEGIN_DECLS
  64. #ifdef __USE_MISC
  65. /* Clone current process. */
  66. extern int clone (int (*__fn) (void *__arg), void *__child_stack,
  67. int __flags, void *__arg, ...) __THROW;
  68. #if 0
  69. /* Unshare the specified resources. */
  70. extern int unshare (int __flags) __THROW;
  71. #endif
  72. #endif
  73. __END_DECLS
  74. #endif /* __ASSEMBLER__ */
  75. #endif /* need schedparam */
  76. #ifndef __ASSEMBLER__
  77. #if !defined __defined_schedparam \
  78. && (defined __need_schedparam || defined _SCHED_H)
  79. # define __defined_schedparam 1
  80. /* Data structure to describe a process' schedulability. */
  81. struct __sched_param
  82. {
  83. int __sched_priority;
  84. };
  85. # undef __need_schedparam
  86. #endif
  87. #if 0
  88. #if defined _SCHED_H && !defined __cpu_set_t_defined
  89. # define __cpu_set_t_defined
  90. /* Size definition for CPU sets. */
  91. # define __CPU_SETSIZE 1024
  92. # define __NCPUBITS (8 * sizeof (__cpu_mask))
  93. /* Type for array elements in 'cpu_set'. */
  94. typedef unsigned long int __cpu_mask;
  95. /* Basic access functions. */
  96. # define __CPUELT(cpu) ((cpu) / __NCPUBITS)
  97. # define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS))
  98. /* Data structure to describe CPU mask. */
  99. typedef struct
  100. {
  101. __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
  102. } cpu_set_t;
  103. /* Access functions for CPU masks. */
  104. # define __CPU_ZERO(cpusetp) \
  105. do { \
  106. unsigned int __i; \
  107. cpu_set_t *__arr = (cpusetp); \
  108. for (__i = 0; __i < sizeof (cpu_set_t) / sizeof (__cpu_mask); ++__i) \
  109. __arr->__bits[__i] = 0; \
  110. } while (0)
  111. # define __CPU_SET(cpu, cpusetp) \
  112. ((cpusetp)->__bits[__CPUELT (cpu)] |= __CPUMASK (cpu))
  113. # define __CPU_CLR(cpu, cpusetp) \
  114. ((cpusetp)->__bits[__CPUELT (cpu)] &= ~__CPUMASK (cpu))
  115. # define __CPU_ISSET(cpu, cpusetp) \
  116. (((cpusetp)->__bits[__CPUELT (cpu)] & __CPUMASK (cpu)) != 0)
  117. #endif
  118. #endif
  119. #endif /* __ASSEMBLER__ */