forked from Imagelibrary/rtems
@@ -769,6 +769,7 @@ librtemscpu_a_SOURCES += rtems/src/schedulergetprocessorset.c
|
|||||||
librtemscpu_a_SOURCES += rtems/src/scheduleridentbyprocessor.c
|
librtemscpu_a_SOURCES += rtems/src/scheduleridentbyprocessor.c
|
||||||
librtemscpu_a_SOURCES += rtems/src/scheduleridentbyprocessorset.c
|
librtemscpu_a_SOURCES += rtems/src/scheduleridentbyprocessorset.c
|
||||||
librtemscpu_a_SOURCES += rtems/src/schedulerident.c
|
librtemscpu_a_SOURCES += rtems/src/schedulerident.c
|
||||||
|
librtemscpu_a_SOURCES += rtems/src/schedulermaptoposix.c
|
||||||
librtemscpu_a_SOURCES += rtems/src/schedulerremoveprocessor.c
|
librtemscpu_a_SOURCES += rtems/src/schedulerremoveprocessor.c
|
||||||
librtemscpu_a_SOURCES += rtems/src/sem.c
|
librtemscpu_a_SOURCES += rtems/src/sem.c
|
||||||
librtemscpu_a_SOURCES += rtems/src/semcreate.c
|
librtemscpu_a_SOURCES += rtems/src/semcreate.c
|
||||||
|
|||||||
@@ -736,6 +736,24 @@ rtems_status_code rtems_scheduler_get_maximum_priority(
|
|||||||
rtems_task_priority *priority
|
rtems_task_priority *priority
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Map a task priority to the corresponding POSIX thread priority.
|
||||||
|
*
|
||||||
|
* @param scheduler_id Identifier of the scheduler instance.
|
||||||
|
* @param priority The task priority to map.
|
||||||
|
* @param[out] posix_priority Pointer to a POSIX thread priority value.
|
||||||
|
*
|
||||||
|
* @retval RTEMS_SUCCESSFUL Successful operation.
|
||||||
|
* @retval RTEMS_INVALID_ADDRESS The @a posix_priority parameter is @c NULL.
|
||||||
|
* @retval RTEMS_INVALID_ID Invalid scheduler instance identifier.
|
||||||
|
* @retval RTEMS_INVALID_PRIORITY Invalid task priority.
|
||||||
|
*/
|
||||||
|
rtems_status_code rtems_scheduler_map_priority_to_posix(
|
||||||
|
rtems_id scheduler_id,
|
||||||
|
rtems_task_priority priority,
|
||||||
|
int *posix_priority
|
||||||
|
);
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
70
cpukit/rtems/src/schedulermaptoposix.c
Normal file
70
cpukit/rtems/src/schedulermaptoposix.c
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
*
|
||||||
|
* @ingroup ClassicTasks
|
||||||
|
*
|
||||||
|
* @brief Implementation of rtems_scheduler_map_priority_to_posix().
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <rtems/rtems/tasks.h>
|
||||||
|
#include <rtems/score/schedulerimpl.h>
|
||||||
|
|
||||||
|
rtems_status_code rtems_scheduler_map_priority_to_posix(
|
||||||
|
rtems_id scheduler_id,
|
||||||
|
rtems_task_priority priority,
|
||||||
|
int *posix_priority
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const Scheduler_Control *scheduler;
|
||||||
|
|
||||||
|
if ( posix_priority == NULL ) {
|
||||||
|
return RTEMS_INVALID_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
scheduler = _Scheduler_Get_by_id( scheduler_id );
|
||||||
|
if ( scheduler == NULL ) {
|
||||||
|
return RTEMS_INVALID_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( priority < 1 ) {
|
||||||
|
return RTEMS_INVALID_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( priority >= scheduler->maximum_priority ) {
|
||||||
|
return RTEMS_INVALID_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
*posix_priority = (int) ( scheduler->maximum_priority - priority );
|
||||||
|
return RTEMS_SUCCESSFUL;
|
||||||
|
}
|
||||||
@@ -1,11 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved.
|
* Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||||
*
|
|
||||||
* embedded brains GmbH
|
|
||||||
* Dornierstr. 4
|
|
||||||
* 82178 Puchheim
|
|
||||||
* Germany
|
|
||||||
* <rtems@embedded-brains.de>
|
|
||||||
*
|
*
|
||||||
* The license and distribution terms for this file may be
|
* The license and distribution terms for this file may be
|
||||||
* found in the file LICENSE in this distribution or at
|
* found in the file LICENSE in this distribution or at
|
||||||
@@ -497,6 +491,49 @@ static void test_scheduler_get_max_prio(void)
|
|||||||
rtems_test_assert(priority == 255);
|
rtems_test_assert(priority == 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_scheduler_map_to_posix(void)
|
||||||
|
{
|
||||||
|
rtems_status_code sc;
|
||||||
|
int posix_priority;
|
||||||
|
rtems_id scheduler_id;
|
||||||
|
|
||||||
|
posix_priority = 123;
|
||||||
|
sc = rtems_scheduler_map_priority_to_posix(invalid_id, 1, &posix_priority);
|
||||||
|
rtems_test_assert(sc == RTEMS_INVALID_ID);
|
||||||
|
rtems_test_assert(posix_priority == 123);
|
||||||
|
|
||||||
|
sc = rtems_task_get_scheduler(RTEMS_SELF, &scheduler_id);
|
||||||
|
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||||
|
|
||||||
|
sc = rtems_scheduler_map_priority_to_posix(scheduler_id, 1, NULL);
|
||||||
|
rtems_test_assert(sc == RTEMS_INVALID_ADDRESS);
|
||||||
|
|
||||||
|
posix_priority = 123;
|
||||||
|
sc = rtems_scheduler_map_priority_to_posix(scheduler_id, 0, &posix_priority);
|
||||||
|
rtems_test_assert(sc == RTEMS_INVALID_PRIORITY);
|
||||||
|
rtems_test_assert(posix_priority == 123);
|
||||||
|
|
||||||
|
posix_priority = 123;
|
||||||
|
sc = rtems_scheduler_map_priority_to_posix(scheduler_id, 255, &posix_priority);
|
||||||
|
rtems_test_assert(sc == RTEMS_INVALID_PRIORITY);
|
||||||
|
rtems_test_assert(posix_priority == 123);
|
||||||
|
|
||||||
|
posix_priority = 123;
|
||||||
|
sc = rtems_scheduler_map_priority_to_posix(scheduler_id, 256, &posix_priority);
|
||||||
|
rtems_test_assert(sc == RTEMS_INVALID_PRIORITY);
|
||||||
|
rtems_test_assert(posix_priority == 123);
|
||||||
|
|
||||||
|
posix_priority = 123;
|
||||||
|
sc = rtems_scheduler_map_priority_to_posix(scheduler_id, 1, &posix_priority);
|
||||||
|
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||||
|
rtems_test_assert(posix_priority == 254);
|
||||||
|
|
||||||
|
posix_priority = 123;
|
||||||
|
sc = rtems_scheduler_map_priority_to_posix(scheduler_id, 254, &posix_priority);
|
||||||
|
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||||
|
rtems_test_assert(posix_priority == 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_scheduler_get_processors(void)
|
static void test_scheduler_get_processors(void)
|
||||||
{
|
{
|
||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
@@ -625,6 +662,7 @@ static void Init(rtems_task_argument arg)
|
|||||||
test_task_get_set_scheduler();
|
test_task_get_set_scheduler();
|
||||||
test_scheduler_ident();
|
test_scheduler_ident();
|
||||||
test_scheduler_get_max_prio();
|
test_scheduler_get_max_prio();
|
||||||
|
test_scheduler_map_to_posix();
|
||||||
test_scheduler_get_processors();
|
test_scheduler_get_processors();
|
||||||
test_scheduler_add_remove_processors();
|
test_scheduler_add_remove_processors();
|
||||||
test_task_get_priority();
|
test_task_get_priority();
|
||||||
|
|||||||
Reference in New Issue
Block a user