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