1 /* 2 * Module: sched.h 3 * 4 * Purpose: 5 * Provides an implementation of POSIX realtime extensions 6 * as defined in 7 * 8 * POSIX 1003.1b-1993 (POSIX.1b) 9 * 10 * -------------------------------------------------------------------------- 11 * 12 * Pthreads-embedded (PTE) - POSIX Threads Library for embedded systems 13 * Copyright(C) 2008 Jason Schmidlapp 14 * 15 * Contact Email: jschmidlapp@users.sourceforge.net 16 * 17 * 18 * Pthreads-embedded (PTE) - POSIX Threads Library for embedded systems 19 * Copyright(C) 2008 Jason Schmidlapp 20 * 21 * Contact Email: jschmidlapp@users.sourceforge.net 22 * 23 * 24 * Based upon Pthreads-win32 - POSIX Threads Library for Win32 25 * Copyright(C) 1998 John E. Bossom 26 * Copyright(C) 1999,2005 Pthreads-win32 contributors 27 * 28 * Contact Email: rpj@callisto.canberra.edu.au 29 * 30 * The original list of contributors to the Pthreads-win32 project 31 * is contained in the file CONTRIBUTORS.ptw32 included with the 32 * source code distribution. The list can also be seen at the 33 * following World Wide Web location: 34 * http://sources.redhat.com/pthreads-win32/contributors.html 35 * 36 * This library is free software; you can redistribute it and/or 37 * modify it under the terms of the GNU Lesser General Public 38 * License as published by the Free Software Foundation; either 39 * version 2 of the License, or (at your option) any later version. 40 * 41 * This library is distributed in the hope that it will be useful, 42 * but WITHOUT ANY WARRANTY; without even the implied warranty of 43 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 44 * Lesser General Public License for more details. 45 * 46 * You should have received a copy of the GNU Lesser General Public 47 * License along with this library in the file COPYING.LIB; 48 * if not, write to the Free Software Foundation, Inc., 49 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 50 */ 51 #ifndef _SCHED_H 52 #define _SCHED_H 53 54 #include <pte_types.h> 55 56 #undef PTE_LEVEL 57 58 #if defined(_POSIX_SOURCE) 59 #define PTE_LEVEL 0 60 /* Early POSIX */ 61 #endif 62 63 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 64 #undef PTE_LEVEL 65 #define PTE_LEVEL 1 66 /* Include 1b, 1c and 1d */ 67 #endif 68 69 #if defined(INCLUDE_NP) 70 #undef PTE_LEVEL 71 #define PTE_LEVEL 2 72 /* Include Non-Portable extensions */ 73 #endif 74 75 #define PTE_LEVEL_MAX 3 76 77 #if !defined(PTE_LEVEL) 78 #define PTE_LEVEL PTE_LEVEL_MAX 79 /* Include everything */ 80 #endif 81 82 /* 83 * 84 */ 85 86 /* Thread scheduling policies */ 87 88 enum 89 { 90 SCHED_OTHER = 0, 91 SCHED_FIFO, 92 SCHED_RR, 93 SCHED_MIN = SCHED_OTHER, 94 SCHED_MAX = SCHED_RR 95 }; 96 97 struct sched_param 98 { 99 int sched_priority; 100 }; 101 102 #ifdef __cplusplus 103 extern "C" 104 { 105 #endif /* __cplusplus */ 106 107 int sched_yield (void); 108 109 int sched_get_priority_min (int policy); 110 111 int sched_get_priority_max (int policy); 112 113 int sched_setscheduler (pid_t pid, int policy); 114 115 /* 116 * Note that this macro returns ENOTSUP rather than 117 * ENOSYS as might be expected. However, returning ENOSYS 118 * should mean that sched_get_priority_{min,max} are 119 * not implemented as well as sched_rr_get_interval. 120 * This is not the case, since we just don't support 121 * round-robin scheduling. Therefore I have chosen to 122 * return the same value as sched_setscheduler when 123 * SCHED_RR is passed to it. 124 */ 125 #define sched_rr_get_interval(_pid, _interval) \ 126 ( errno = ENOTSUP, (int) -1 ) 127 128 129 #ifdef __cplusplus 130 } /* End of extern "C" */ 131 #endif /* __cplusplus */ 132 133 #undef PTE_LEVEL 134 #undef PTE_LEVEL_MAX 135 136 #endif /* !_SCHED_H */ 137 138