Back to index

glibc  2.9
sched.h
Go to the documentation of this file.
00001 /* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.
00002    Copyright (C) 1996,1997,1999,2001-2004,2007 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef       _SCHED_H
00021 #define       _SCHED_H      1
00022 
00023 #include <features.h>
00024 
00025 /* Get type definitions.  */
00026 #include <bits/types.h>
00027 
00028 #define __need_size_t
00029 #include <stddef.h>
00030 
00031 #define __need_timespec
00032 #include <time.h>
00033 
00034 /* Get system specific constant and data structure definitions.  */
00035 #include <bits/sched.h>
00036 /* Define the real names for the elements of `struct sched_param'.  */
00037 #define sched_priority      __sched_priority
00038 
00039 
00040 __BEGIN_DECLS
00041 
00042 /* Set scheduling parameters for a process.  */
00043 extern int sched_setparam (__pid_t __pid, __const struct sched_param *__param)
00044      __THROW;
00045 
00046 /* Retrieve scheduling parameters for a particular process.  */
00047 extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __THROW;
00048 
00049 /* Set scheduling algorithm and/or parameters for a process.  */
00050 extern int sched_setscheduler (__pid_t __pid, int __policy,
00051                             __const struct sched_param *__param) __THROW;
00052 
00053 /* Retrieve scheduling algorithm for a particular purpose.  */
00054 extern int sched_getscheduler (__pid_t __pid) __THROW;
00055 
00056 /* Yield the processor.  */
00057 extern int sched_yield (void) __THROW;
00058 
00059 /* Get maximum priority value for a scheduler.  */
00060 extern int sched_get_priority_max (int __algorithm) __THROW;
00061 
00062 /* Get minimum priority value for a scheduler.  */
00063 extern int sched_get_priority_min (int __algorithm) __THROW;
00064 
00065 /* Get the SCHED_RR interval for the named process.  */
00066 extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
00067 
00068 
00069 #ifdef __USE_GNU
00070 /* Access macros for `cpu_set'.  */
00071 # define CPU_SETSIZE __CPU_SETSIZE
00072 # define CPU_SET(cpu, cpusetp)      __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
00073 # define CPU_CLR(cpu, cpusetp)      __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
00074 # define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
00075                                           cpusetp)
00076 # define CPU_ZERO(cpusetp)   __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)
00077 # define CPU_COUNT(cpusetp)  __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)
00078 
00079 # define CPU_SET_S(cpu, setsize, cpusetp)   __CPU_SET_S (cpu, setsize, cpusetp)
00080 # define CPU_CLR_S(cpu, setsize, cpusetp)   __CPU_CLR_S (cpu, setsize, cpusetp)
00081 # define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \
00082                                                     cpusetp)
00083 # define CPU_ZERO_S(setsize, cpusetp)         __CPU_ZERO_S (setsize, cpusetp)
00084 # define CPU_COUNT_S(setsize, cpusetp)        __CPU_COUNT_S (setsize, cpusetp)
00085 
00086 # define CPU_EQUAL(cpusetp1, cpusetp2) \
00087   __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
00088 # define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
00089   __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)
00090 
00091 # define CPU_AND(destset, srcset1, srcset2) \
00092   __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)
00093 # define CPU_OR(destset, srcset1, srcset2) \
00094   __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
00095 # define CPU_XOR(destset, srcset1, srcset2) \
00096   __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)
00097 # define CPU_AND_S(setsize, destset, srcset1, srcset2) \
00098   __CPU_OP_S (setsize, destset, srcset1, srcset2, &)
00099 # define CPU_OR_S(setsize, destset, srcset1, srcset2) \
00100   __CPU_OP_S (setsize, destset, srcset1, srcset2, |)
00101 # define CPU_XOR_S(setsize, destset, srcset1, srcset2) \
00102   __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)
00103 
00104 # define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
00105 # define CPU_ALLOC(count) __CPU_ALLOC (count)
00106 # define CPU_FREE(cpuset) __CPU_FREE (cpuset)
00107 
00108 
00109 /* Set the CPU affinity for a task */
00110 extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
00111                            __const cpu_set_t *__cpuset) __THROW;
00112 
00113 /* Get the CPU affinity for a task */
00114 extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
00115                            cpu_set_t *__cpuset) __THROW;
00116 #endif
00117 
00118 __END_DECLS
00119 
00120 #endif /* sched.h */