From 5a32c486f9b7bd8687af253931b47d7abb091bc3 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 14 Jun 2016 15:57:54 +0200 Subject: posix: Make POSIX API aware of scheduler instances --- cpukit/posix/include/rtems/posix/priorityimpl.h | 85 ++++++++----------------- 1 file changed, 28 insertions(+), 57 deletions(-) (limited to 'cpukit/posix/include/rtems/posix/priorityimpl.h') diff --git a/cpukit/posix/include/rtems/posix/priorityimpl.h b/cpukit/posix/include/rtems/posix/priorityimpl.h index e3f23e748d..d06b600f04 100644 --- a/cpukit/posix/include/rtems/posix/priorityimpl.h +++ b/cpukit/posix/include/rtems/posix/priorityimpl.h @@ -30,29 +30,10 @@ extern "C" { * * @ingroup POSIXAPI * - * @brief Interface to the POSIX Priority Implementation - * - */ -/**@{**/ - -/** - * 1003.1b-1993,2.2.2.80 definition of priority, p. 19 - * - * "Numerically higher values represent higher priorities." - * - * Thus, RTEMS Core has priorities run in the opposite sense of the POSIX API. + * @brief Interface to the POSIX Priority Implementation. * - * There are only 254 posix priority levels since a task at priority level - * 255 would never run because of the RTEMS idle task. This is necessary - * because GNAT maps the lowest Ada task priority to the lowest thread - * priority. The lowest priority Ada task should get to run, so there is - * a fundamental conflict with having 255 priorities. - * - * But since RTEMS can be configured with fewer than 256 priorities, - * we use the internal constant. + * @{ */ -#define POSIX_SCHEDULER_MAXIMUM_PRIORITY (PRIORITY_MAXIMUM - 1) - /** * This is the numerically least important POSIX priority. @@ -72,53 +53,43 @@ int _POSIX_Priority_Get_maximum( const Scheduler_Control *scheduler ); /** * @brief Check if POSIX priority is valid. * - * 1003.1b-1993,2.2.2.80 definition of priority, p. 19 - * - * "Numerically higher values represent higher priorities." - * - * Thus, RTEMS Core has priorities run in the opposite sense of the POSIX API. - * - * @param[in] priority is the priority to test - * - * @retval TRUE The priority is valid. - * @retval FALSE The priority is invalid. + * According to POSIX, numerically higher values represent higher priorities. + * Thus, SuperCore has priorities run in the opposite sense of the POSIX API. + * + * Let N be the maximum priority of this scheduler instance. The SuperCore + * priority zero is system reserved (PRIORITY_PSEUDO_ISR). There are only + * N - 1 POSIX API priority levels since a thread at SuperCore priority N would + * never run because of the idle threads. This is necessary because GNAT maps + * the lowest Ada task priority to the lowest thread priority. The lowest + * priority Ada task should get to run, so there is a fundamental conflict with + * having N priorities. + * + * @param[in] scheduler The scheduler instance. + * @param[in] priority The POSIX API priority to test. + * + * @retval true The priority is valid. + * @retval false Otherwise. */ bool _POSIX_Priority_Is_valid( - int priority + const Scheduler_Control *scheduler, + int priority ); /** - * @brief Convert POSIX priority to SuperCore priority. - * - * This method converts a POSIX API priority into onto the corresponding - * SuperCore value. - * - * @param[in] priority is the POSIX API priority. - * - * @return This method returns the corresponding SuperCore priority. - */ -RTEMS_INLINE_ROUTINE Priority_Control _POSIX_Priority_To_core( - int priority -) -{ - return (Priority_Control) (POSIX_SCHEDULER_MAXIMUM_PRIORITY - priority + 1); -} - -/** - * @brief Convert SuperCore priority To POSIX priority. - * - * This method converts a SuperCore priority into onto the corresponding - * POSIX API value. + * @brief Converts the SuperCore priority to the corresponding POSIX API + * priority. * - * @param[in] priority is the POSIX API priority. + * @param[in] scheduler The scheduler instance. + * @param[in] priority The SuperCore priority to convert. * - * @return This method returns the corresponding POSIX priority. + * @return The corresponding POSIX API priority. */ RTEMS_INLINE_ROUTINE int _POSIX_Priority_From_core( - Priority_Control priority + const Scheduler_Control *scheduler, + Priority_Control priority ) { - return (POSIX_SCHEDULER_MAXIMUM_PRIORITY - priority + 1); + return (int) ( scheduler->maximum_priority - priority ); } /** @} */ -- cgit v1.2.3