/*1* Module: sched.h2*3* Purpose:4* Provides an implementation of POSIX realtime extensions5* as defined in6*7* POSIX 1003.1b-1993 (POSIX.1b)8*9* --------------------------------------------------------------------------10*11* Pthreads-win32 - POSIX Threads Library for Win3212* Copyright(C) 1998 John E. Bossom13* Copyright(C) 1999,2005 Pthreads-win32 contributors14*15* Contact Email: [email protected]16*17* The current list of contributors is contained18* in the file CONTRIBUTORS included with the source19* code distribution. The list can also be seen at the20* following World Wide Web location:21* http://sources.redhat.com/pthreads-win32/contributors.html22*23* This library is free software; you can redistribute it and/or24* modify it under the terms of the GNU Lesser General Public25* License as published by the Free Software Foundation; either26* version 2 of the License, or (at your option) any later version.27*28* This library is distributed in the hope that it will be useful,29* but WITHOUT ANY WARRANTY; without even the implied warranty of30* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU31* Lesser General Public License for more details.32*33* You should have received a copy of the GNU Lesser General Public34* License along with this library in the file COPYING.LIB;35* if not, write to the Free Software Foundation, Inc.,36* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA37*/38#if !defined(_SCHED_H)39#define _SCHED_H4041#undef PTW32_SCHED_LEVEL4243#if defined(_POSIX_SOURCE)44#define PTW32_SCHED_LEVEL 045/* Early POSIX */46#endif4748#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 19930949#undef PTW32_SCHED_LEVEL50#define PTW32_SCHED_LEVEL 151/* Include 1b, 1c and 1d */52#endif5354#if defined(INCLUDE_NP)55#undef PTW32_SCHED_LEVEL56#define PTW32_SCHED_LEVEL 257/* Include Non-Portable extensions */58#endif5960#define PTW32_SCHED_LEVEL_MAX 36162#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL)63#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX64/* Include everything */65#endif666768#if defined(__GNUC__) && !defined(__declspec)69# error Please upgrade your GNU compiler to one that supports __declspec.70#endif7172/*73* When building the library, you should define PTW32_BUILD so that74* the variables/functions are exported correctly. When using the library,75* do NOT define PTW32_BUILD, and then the variables/functions will76* be imported correctly.77*/78#if !defined(PTW32_STATIC_LIB)79# if defined(PTW32_BUILD)80# define PTW32_DLLPORT __declspec (dllexport)81# else82# define PTW32_DLLPORT __declspec (dllimport)83# endif84#else85# define PTW32_DLLPORT86#endif8788/*89* This is a duplicate of what is in the autoconf config.h,90* which is only used when building the pthread-win32 libraries.91*/9293#if !defined(PTW32_CONFIG_H)94# if defined(WINCE)95# define NEED_ERRNO96# define NEED_SEM97# endif98# if defined(__MINGW64__)99# define HAVE_STRUCT_TIMESPEC100# define HAVE_MODE_T101# elif defined(_UWIN) || defined(__MINGW32__)102# define HAVE_MODE_T103# endif104#endif105106/*107*108*/109110#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX111#if defined(NEED_ERRNO)112#include "need_errno.h"113#else114#include <errno.h>115#endif116#endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */117118#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN)119# if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX120/* For pid_t */121# include <sys/types.h>122/* Required by Unix 98 */123# include <time.h>124# else125typedef int pid_t;126# endif127#else128typedef int pid_t;129#endif130131/* Thread scheduling policies */132133enum {134SCHED_OTHER = 0,135SCHED_FIFO,136SCHED_RR,137SCHED_MIN = SCHED_OTHER,138SCHED_MAX = SCHED_RR139};140141struct sched_param {142int sched_priority;143};144145#if defined(__cplusplus)146extern "C"147{148#endif /* __cplusplus */149150PTW32_DLLPORT int __cdecl sched_yield (void);151152PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy);153154PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy);155156PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy);157158PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);159160/*161* Note that this macro returns ENOTSUP rather than162* ENOSYS as might be expected. However, returning ENOSYS163* should mean that sched_get_priority_{min,max} are164* not implemented as well as sched_rr_get_interval.165* This is not the case, since we just don't support166* round-robin scheduling. Therefore I have chosen to167* return the same value as sched_setscheduler when168* SCHED_RR is passed to it.169*/170#define sched_rr_get_interval(_pid, _interval) \171( errno = ENOTSUP, (int) -1 )172173174#if defined(__cplusplus)175} /* End of extern "C" */176#endif /* __cplusplus */177178#undef PTW32_SCHED_LEVEL179#undef PTW32_SCHED_LEVEL_MAX180181#endif /* !_SCHED_H */182183184185