source: rtems/cpukit/posix/include/rtems/posix/priorityimpl.h @ 7dfb4b9

5
Last change on this file since 7dfb4b9 was 7dfb4b9, checked in by Sebastian Huber <sebastian.huber@…>, on 05/19/16 at 09:20:58

score: Add per scheduler instance maximum priority

The priority values are only valid within a scheduler instance. Thus,
the maximum priority value must be defined per scheduler instance. The
first scheduler instance defines PRIORITY_MAXIMUM. This implies that
RTEMS_MAXIMUM_PRIORITY and POSIX_SCHEDULER_MAXIMUM_PRIORITY are only
valid for threads of the first scheduler instance. Further
API/implementation changes are necessary to fix this.

Update #2556.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief POSIX Priority Support
5 *
6 * This include file defines the interface to the POSIX priority
7 * implementation.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2011.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_POSIX_PRIORITYIMPL_H
20#define _RTEMS_POSIX_PRIORITYIMPL_H
21
22#include <rtems/score/scheduler.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/**
29 * @defgroup POSIX_PRIORITY POSIX Priority Support
30 *
31 * @ingroup POSIXAPI
32 *
33 * @brief Interface to the POSIX Priority Implementation
34 *
35 */
36/**@{**/
37
38/**
39 * 1003.1b-1993,2.2.2.80 definition of priority, p. 19
40 *
41 * "Numerically higher values represent higher priorities."
42 *
43 * Thus, RTEMS Core has priorities run in the opposite sense of the POSIX API.
44 *
45 * There are only 254 posix priority levels since a task at priority level
46 * 255 would never run because of the RTEMS idle task.  This is necessary
47 * because GNAT maps the lowest Ada task priority to the lowest thread
48 * priority.  The lowest priority Ada task should get to run, so there is
49 * a fundamental conflict with having 255 priorities.
50 *
51 * But since RTEMS can be configured with fewer than 256 priorities,
52 * we use the internal constant.
53 */
54#define POSIX_SCHEDULER_MAXIMUM_PRIORITY (PRIORITY_MAXIMUM - 1)
55
56
57/**
58 *  This is the numerically least important POSIX priority.
59 */
60#define POSIX_SCHEDULER_MINIMUM_PRIORITY (1)
61
62/**
63 * @brief Check if POSIX priority is valid.
64 *
65 * 1003.1b-1993,2.2.2.80 definition of priority, p. 19
66 *
67 * "Numerically higher values represent higher priorities."
68 *
69 * Thus, RTEMS Core has priorities run in the opposite sense of the POSIX API.
70 *
71 * @param[in] priority is the priority to test
72 *
73 * @retval TRUE The priority is valid.
74 * @retval FALSE The priority is invalid.
75 */
76bool _POSIX_Priority_Is_valid(
77  int priority
78);
79
80/**
81 * @brief Convert POSIX priority to SuperCore priority.
82 *
83 * This method converts a POSIX API priority into onto the corresponding
84 * SuperCore value.
85 *
86 * @param[in] priority is the POSIX API priority.
87 *
88 * @return This method returns the corresponding SuperCore priority.
89 */
90RTEMS_INLINE_ROUTINE Priority_Control _POSIX_Priority_To_core(
91  int priority
92)
93{
94  return (Priority_Control) (POSIX_SCHEDULER_MAXIMUM_PRIORITY - priority + 1);
95}
96
97/**
98 * @brief Convert SuperCore priority To POSIX priority.
99 *
100 * This method converts a SuperCore priority into onto the corresponding
101 * POSIX API value.
102 *
103 * @param[in] priority is the POSIX API priority.
104 *
105 * @return This method returns the corresponding POSIX priority.
106 */
107RTEMS_INLINE_ROUTINE int _POSIX_Priority_From_core(
108  Priority_Control priority
109)
110{
111  return (POSIX_SCHEDULER_MAXIMUM_PRIORITY - priority + 1);
112}
113
114/** @} */
115
116#ifdef __cplusplus
117}
118#endif
119
120#endif
Note: See TracBrowser for help on using the repository browser.