source: rtems/cpukit/include/rtems/posix/priorityimpl.h

Last change on this file was a660e9dc, checked in by Sebastian Huber <sebastian.huber@…>, on 09/08/22 at 08:37:05

Do not use RTEMS_INLINE_ROUTINE

Directly use "static inline" which is available in C99 and later. This brings
the RTEMS implementation closer to standard C.

Close #3935.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @brief POSIX Priority Support
7 *
8 * This include file defines the interface to the POSIX priority
9 * implementation.
10 */
11
12/*
13 *  COPYRIGHT (c) 1989-2011.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 *    notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 *    notice, this list of conditions and the following disclaimer in the
23 *    documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _RTEMS_POSIX_PRIORITYIMPL_H
39#define _RTEMS_POSIX_PRIORITYIMPL_H
40
41#include <rtems/score/scheduler.h>
42#include <rtems/score/assert.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/**
49 * @defgroup POSIX_PRIORITY POSIX Priority Support
50 *
51 * @ingroup POSIXAPI
52 *
53 * @brief Interface to the POSIX Priority Implementation.
54 *
55 * @{
56 */
57
58/**
59 *  This is the numerically least important POSIX priority.
60 */
61#define POSIX_SCHEDULER_MINIMUM_PRIORITY (1)
62
63/**
64 * @brief Gets the maximum POSIX API priority for this scheduler instance.
65 *
66 * Such a priority is valid.  A scheduler instance may support priority values
67 * that are not representable as an integer.
68 *
69 * @return The maximum POSIX API priority for this scheduler instance.
70 */
71static inline int _POSIX_Priority_Get_maximum(
72  const Scheduler_Control *scheduler
73)
74{
75  _Assert( (int) scheduler->maximum_priority > 1 );
76  return (int) scheduler->maximum_priority - 1;
77}
78
79/**
80 * @brief Converts the POSIX API priority to the corresponding SuperCore
81 * priority and validates it.
82 *
83 * According to POSIX, numerically higher values represent higher priorities.
84 * Thus, SuperCore has priorities run in the opposite sense of the POSIX API.
85 *
86 * Let N be the maximum priority of this scheduler instance.   The SuperCore
87 * priority zero is system reserved (PRIORITY_MINIMUM).  There are only
88 * N - 1 POSIX API priority levels since a thread at SuperCore priority N would
89 * never run because of the idle threads.  This is necessary because GNAT maps
90 * the lowest Ada task priority to the lowest thread priority.  The lowest
91 * priority Ada task should get to run, so there is a fundamental conflict with
92 * having N priorities.
93 *
94 * @param[in] scheduler The scheduler instance.
95 * @param[in] priority The POSIX API priority to convert and validate.
96 * @param[out] valid Indicates if the POSIX API priority is valid and a
97 *   corresponding SuperCore priority in the specified scheduler instance
98 *   exists.
99 *
100 * @return The corresponding SuperCore priority.
101 */
102Priority_Control _POSIX_Priority_To_core(
103  const Scheduler_Control *scheduler,
104  int                      priority,
105  bool                    *valid
106);
107
108/**
109 * @brief Converts the SuperCore priority to the corresponding POSIX API
110 * priority.
111 *
112 * @param[in] scheduler The scheduler instance.
113 * @param[in] priority The SuperCore priority to convert.
114 *
115 * @return The corresponding POSIX API priority.
116 */
117int _POSIX_Priority_From_core(
118  const Scheduler_Control *scheduler,
119  Priority_Control         priority
120);
121
122/** @} */
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif
Note: See TracBrowser for help on using the repository browser.