/[pcsx2_0.9.7]/trunk/3rdparty/w32pthreads/sched_get_priority_max.c
ViewVC logotype

Contents of /trunk/3rdparty/w32pthreads/sched_get_priority_max.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations) (download)
Mon Sep 6 11:40:06 2010 UTC (9 years, 5 months ago) by william
File MIME type: text/plain
File size: 6453 byte(s)
exported r3113 from ./upstream/trunk
1 /*
2 * sched_get_priority_max.c
3 *
4 * Description:
5 * POSIX thread functions that deal with thread scheduling.
6 *
7 * --------------------------------------------------------------------------
8 *
9 * Pthreads-win32 - POSIX Threads Library for Win32
10 * Copyright(C) 1998 John E. Bossom
11 * Copyright(C) 1999,2005 Pthreads-win32 contributors
12 *
13 * Contact Email: rpj@callisto.canberra.edu.au
14 *
15 * The current list of contributors is contained
16 * in the file CONTRIBUTORS included with the source
17 * code distribution. The list can also be seen at the
18 * following World Wide Web location:
19 * http://sources.redhat.com/pthreads-win32/contributors.html
20 *
21 * This library is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU Lesser General Public
23 * License as published by the Free Software Foundation; either
24 * version 2 of the License, or (at your option) any later version.
25 *
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
30 *
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library in the file COPYING.LIB;
33 * if not, write to the Free Software Foundation, Inc.,
34 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
35 */
36
37 #include "ptw32pch.h"
38 #include "sched.h"
39
40 /*
41 * On Windows98, THREAD_PRIORITY_LOWEST is (-2) and
42 * THREAD_PRIORITY_HIGHEST is 2, and everything works just fine.
43 *
44 * On WinCE 3.0, it so happen that THREAD_PRIORITY_LOWEST is 5
45 * and THREAD_PRIORITY_HIGHEST is 1 (yes, I know, it is funny:
46 * highest priority use smaller numbers) and the following happens:
47 *
48 * sched_get_priority_min() returns 5
49 * sched_get_priority_max() returns 1
50 *
51 * The following table shows the base priority levels for combinations
52 * of priority class and priority value in Win32.
53 *
54 * Process Priority Class Thread Priority Level
55 * -----------------------------------------------------------------
56 * 1 IDLE_PRIORITY_CLASS THREAD_PRIORITY_IDLE
57 * 1 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE
58 * 1 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE
59 * 1 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE
60 * 1 HIGH_PRIORITY_CLASS THREAD_PRIORITY_IDLE
61 * 2 IDLE_PRIORITY_CLASS THREAD_PRIORITY_LOWEST
62 * 3 IDLE_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL
63 * 4 IDLE_PRIORITY_CLASS THREAD_PRIORITY_NORMAL
64 * 4 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST
65 * 5 IDLE_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL
66 * 5 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL
67 * 5 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST
68 * 6 IDLE_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST
69 * 6 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL
70 * 6 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL
71 * 7 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL
72 * 7 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL
73 * 7 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST
74 * 8 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST
75 * 8 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL
76 * 8 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL
77 * 8 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST
78 * 9 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST
79 * 9 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL
80 * 9 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL
81 * 10 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL
82 * 10 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL
83 * 11 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST
84 * 11 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL
85 * 11 HIGH_PRIORITY_CLASS THREAD_PRIORITY_LOWEST
86 * 12 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST
87 * 12 HIGH_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL
88 * 13 HIGH_PRIORITY_CLASS THREAD_PRIORITY_NORMAL
89 * 14 HIGH_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL
90 * 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST
91 * 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL
92 * 15 IDLE_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL
93 * 15 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL
94 * 15 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL
95 * 15 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL
96 * 16 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_IDLE
97 * 17 REALTIME_PRIORITY_CLASS -7
98 * 18 REALTIME_PRIORITY_CLASS -6
99 * 19 REALTIME_PRIORITY_CLASS -5
100 * 20 REALTIME_PRIORITY_CLASS -4
101 * 21 REALTIME_PRIORITY_CLASS -3
102 * 22 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_LOWEST
103 * 23 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL
104 * 24 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_NORMAL
105 * 25 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL
106 * 26 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST
107 * 27 REALTIME_PRIORITY_CLASS 3
108 * 28 REALTIME_PRIORITY_CLASS 4
109 * 29 REALTIME_PRIORITY_CLASS 5
110 * 30 REALTIME_PRIORITY_CLASS 6
111 * 31 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL
112 *
113 * Windows NT: Values -7, -6, -5, -4, -3, 3, 4, 5, and 6 are not supported.
114 */
115
116
117 int
118 sched_get_priority_max (int policy)
119 {
120 if (policy < SCHED_MIN || policy > SCHED_MAX)
121 {
122 errno = EINVAL;
123 return -1;
124 }
125
126 #if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL)
127 /* WinCE? */
128 return PTW32_MAX (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL);
129 #else
130 /* This is independent of scheduling policy in Win32. */
131 return PTW32_MAX (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL);
132 #endif
133 }

  ViewVC Help
Powered by ViewVC 1.1.22