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 |
---|
25 | extern "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 | * This is the numerically least important POSIX priority. |
---|
40 | */ |
---|
41 | #define POSIX_SCHEDULER_MINIMUM_PRIORITY (1) |
---|
42 | |
---|
43 | /** |
---|
44 | * @brief Gets the maximum POSIX API priority for this scheduler instance. |
---|
45 | * |
---|
46 | * Such a priority is valid. A scheduler instance may support priority values |
---|
47 | * that are not representable as an integer. |
---|
48 | * |
---|
49 | * @return The maximum POSIX API priority for this scheduler instance. |
---|
50 | */ |
---|
51 | int _POSIX_Priority_Get_maximum( const Scheduler_Control *scheduler ); |
---|
52 | |
---|
53 | /** |
---|
54 | * @brief Check if POSIX priority is valid. |
---|
55 | * |
---|
56 | * According to POSIX, numerically higher values represent higher priorities. |
---|
57 | * Thus, SuperCore has priorities run in the opposite sense of the POSIX API. |
---|
58 | * |
---|
59 | * Let N be the maximum priority of this scheduler instance. The SuperCore |
---|
60 | * priority zero is system reserved (PRIORITY_PSEUDO_ISR). There are only |
---|
61 | * N - 1 POSIX API priority levels since a thread at SuperCore priority N would |
---|
62 | * never run because of the idle threads. This is necessary because GNAT maps |
---|
63 | * the lowest Ada task priority to the lowest thread priority. The lowest |
---|
64 | * priority Ada task should get to run, so there is a fundamental conflict with |
---|
65 | * having N priorities. |
---|
66 | * |
---|
67 | * @param[in] scheduler The scheduler instance. |
---|
68 | * @param[in] priority The POSIX API priority to test. |
---|
69 | * |
---|
70 | * @retval true The priority is valid. |
---|
71 | * @retval false Otherwise. |
---|
72 | */ |
---|
73 | bool _POSIX_Priority_Is_valid( |
---|
74 | const Scheduler_Control *scheduler, |
---|
75 | int priority |
---|
76 | ); |
---|
77 | |
---|
78 | /** |
---|
79 | * @brief Converts the SuperCore priority to the corresponding POSIX API |
---|
80 | * priority. |
---|
81 | * |
---|
82 | * @param[in] scheduler The scheduler instance. |
---|
83 | * @param[in] priority The SuperCore priority to convert. |
---|
84 | * |
---|
85 | * @return The corresponding POSIX API priority. |
---|
86 | */ |
---|
87 | RTEMS_INLINE_ROUTINE int _POSIX_Priority_From_core( |
---|
88 | const Scheduler_Control *scheduler, |
---|
89 | Priority_Control priority |
---|
90 | ) |
---|
91 | { |
---|
92 | return (int) ( scheduler->maximum_priority - priority ); |
---|
93 | } |
---|
94 | |
---|
95 | /** @} */ |
---|
96 | |
---|
97 | #ifdef __cplusplus |
---|
98 | } |
---|
99 | #endif |
---|
100 | |
---|
101 | #endif |
---|