Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

sched.h

Go to the documentation of this file.
00001 /*
00002  * Module: sched.h
00003  *
00004  * Purpose:
00005  *      Provides an implementation of POSIX realtime extensions
00006  *      as defined in 
00007  *
00008  *              POSIX 1003.1b-1993      (POSIX.1b)
00009  *
00010  * --------------------------------------------------------------------------
00011  *
00012  *      Pthreads-win32 - POSIX Threads Library for Win32
00013  *      Copyright(C) 1998 John E. Bossom
00014  *      Copyright(C) 1999,2003 Pthreads-win32 contributors
00015  * 
00016  *      Contact Email: rpj@callisto.canberra.edu.au
00017  * 
00018  *      The current list of contributors is contained
00019  *      in the file CONTRIBUTORS included with the source
00020  *      code distribution. The list can also be seen at the
00021  *      following World Wide Web location:
00022  *      http://sources.redhat.com/pthreads-win32/contributors.html
00023  * 
00024  *      This library is free software; you can redistribute it and/or
00025  *      modify it under the terms of the GNU Lesser General Public
00026  *      License as published by the Free Software Foundation; either
00027  *      version 2 of the License, or (at your option) any later version.
00028  * 
00029  *      This library is distributed in the hope that it will be useful,
00030  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00031  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00032  *      Lesser General Public License for more details.
00033  * 
00034  *      You should have received a copy of the GNU Lesser General Public
00035  *      License along with this library in the file COPYING.LIB;
00036  *      if not, write to the Free Software Foundation, Inc.,
00037  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00038  */
00039 #ifndef _SCHED_H
00040 #define _SCHED_H
00041 
00042 #undef PTW32_LEVEL
00043 
00044 #if defined(_POSIX_SOURCE)
00045 #define PTW32_LEVEL 0
00046 /* Early POSIX */
00047 #endif
00048 
00049 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
00050 #undef PTW32_LEVEL
00051 #define PTW32_LEVEL 1
00052 /* Include 1b, 1c and 1d */
00053 #endif
00054 
00055 #if defined(INCLUDE_NP)
00056 #undef PTW32_LEVEL
00057 #define PTW32_LEVEL 2
00058 /* Include Non-Portable extensions */
00059 #endif
00060 
00061 #define PTW32_LEVEL_MAX 3
00062 
00063 #if !defined(PTW32_LEVEL)
00064 #define PTW32_LEVEL PTW32_LEVEL_MAX
00065 /* Include everything */
00066 #endif
00067 
00068 
00069 #if __GNUC__ && ! defined (__declspec)
00070 # error Please upgrade your GNU compiler to one that supports __declspec.
00071 #endif
00072 
00073 /*
00074  * When building the DLL code, you should define PTW32_BUILD so that
00075  * the variables/functions are exported correctly. When using the DLL,
00076  * do NOT define PTW32_BUILD, and then the variables/functions will
00077  * be imported correctly.
00078  */
00079 #ifdef PTW32_BUILD
00080 # define PTW32_DLLPORT __declspec (dllexport)
00081 #else
00082 # define PTW32_DLLPORT __declspec (dllimport)
00083 #endif
00084 
00085 /*
00086  * This is a duplicate of what is in the autoconf config.h,
00087  * which is only used when building the pthread-win32 libraries.
00088  */
00089 
00090 #ifndef PTW32_CONFIG_H
00091 #  if defined(WINCE)
00092 #    define NEED_ERRNO
00093 #    define NEED_SEM
00094 #  endif
00095 #  if defined(_UWIN) || defined(__MINGW32__)
00096 #    define HAVE_MODE_T
00097 #  endif
00098 #endif
00099 
00100 /*
00101  *
00102  */
00103 
00104 #if PTW32_LEVEL >= PTW32_LEVEL_MAX
00105 #ifdef NEED_ERRNO
00106 #include "need_errno.h"
00107 #else
00108 #include <errno.h>
00109 #endif
00110 #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
00111 
00112 #if defined(__MINGW32__) || defined(_UWIN)
00113 #if PTW32_LEVEL >= PTW32_LEVEL_MAX
00114 /* For pid_t */
00115 #  include <sys/types.h>
00116 /* Required by Unix 98 */
00117 #  include <time.h>
00118 #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
00119 #else
00120 typedef int pid_t;
00121 #endif
00122 
00123 /* Thread scheduling policies */
00124 
00125 enum {
00126   SCHED_OTHER = 0,
00127   SCHED_FIFO,
00128   SCHED_RR,
00129   SCHED_MIN   = SCHED_OTHER,
00130   SCHED_MAX   = SCHED_RR
00131 };
00132 
00133 struct sched_param {
00134   int sched_priority;
00135 };
00136 
00137 #ifdef __cplusplus
00138 extern "C"
00139 {
00140 #endif                          /* __cplusplus */
00141 
00142 PTW32_DLLPORT int sched_yield (void);
00143 
00144 PTW32_DLLPORT int sched_get_priority_min (int policy);
00145 
00146 PTW32_DLLPORT int sched_get_priority_max (int policy);
00147 
00148 PTW32_DLLPORT int sched_setscheduler (pid_t pid, int policy);
00149 
00150 PTW32_DLLPORT int sched_getscheduler (pid_t pid);
00151 
00152 /*
00153  * Note that this macro returns ENOTSUP rather than
00154  * ENOSYS as might be expected. However, returning ENOSYS
00155  * should mean that sched_get_priority_{min,max} are
00156  * not implemented as well as sched_rr_get_interval.
00157  * This is not the case, since we just don't support
00158  * round-robin scheduling. Therefore I have chosen to
00159  * return the same value as sched_setscheduler when
00160  * SCHED_RR is passed to it.
00161  */
00162 #define sched_rr_get_interval(_pid, _interval) \
00163   ( errno = ENOTSUP, (int) -1 )
00164 
00165 
00166 #ifdef __cplusplus
00167 }                               /* End of extern "C" */
00168 #endif                          /* __cplusplus */
00169 
00170 #undef PTW32_LEVEL
00171 #undef PTW32_LEVEL_MAX
00172 
00173 #endif                          /* !_SCHED_H */
00174 

Generated on Sun May 14 14:51:20 2006 by  doxygen 1.4.2