37#ifndef _RTEMS_SCORE_PRIORITYIMPL_H
38#define _RTEMS_SCORE_PRIORITYIMPL_H
81static inline void _Priority_Actions_initialize_empty(
96static inline void _Priority_Actions_initialize_one(
103#if defined(RTEMS_SMP)
104 aggregation->Action.next = NULL;
106 aggregation->Action.node = node;
107 aggregation->Action.type = type;
109 actions->
actions = aggregation;
120static inline bool _Priority_Actions_is_empty(
124 return actions->
actions == NULL;
140 aggregation = actions->
actions;
152static inline void _Priority_Actions_add(
157#if defined(RTEMS_SMP)
162 _Assert( aggregation->Action.next == NULL );
163 aggregation->Action.next = actions->
actions;
165 actions->
actions = aggregation;
174static inline void _Priority_Node_initialize(
180 _RBTree_Initialize_node( &node->Node.RBTree );
189static inline void _Priority_Node_set_priority(
202static inline void _Priority_Node_set_inactive(
206 _RBTree_Set_off_tree( &node->Node.RBTree );
217static inline bool _Priority_Node_is_active(
221 return !_RBTree_Is_node_off_tree( &node->Node.RBTree );
229static inline void _Priority_Initialize_empty(
233#if defined(RTEMS_DEBUG)
234#if defined(RTEMS_SMP)
235 aggregation->Action.next = NULL;
237 aggregation->Action.node = NULL;
238 aggregation->Action.type = PRIORITY_ACTION_INVALID;
240 _RBTree_Initialize_node( &aggregation->
Node.Node.RBTree );
250static inline void _Priority_Initialize_one(
255#if defined(RTEMS_DEBUG)
256#if defined(RTEMS_SMP)
257 aggregation->Action.next = NULL;
259 aggregation->Action.node = NULL;
260 aggregation->Action.type = PRIORITY_ACTION_INVALID;
262 _Priority_Node_initialize( &aggregation->
Node, node->
priority );
263 _RBTree_Initialize_one( &aggregation->
Contributors, &node->Node.RBTree );
274static inline bool _Priority_Is_empty(
302static inline const Scheduler_Control *_Priority_Get_scheduler(
306#if defined(RTEMS_SMP)
307 return aggregation->scheduler;
333static inline void _Priority_Set_action_node(
338#if defined(RTEMS_SMP)
339 _Assert( aggregation->Action.next == NULL );
341 aggregation->Action.node = node;
350static inline void _Priority_Set_action_type(
355#if defined(RTEMS_SMP)
356 _Assert( aggregation->Action.next == NULL );
358 aggregation->Action.type = type;
369static inline void _Priority_Set_action(
375#if defined(RTEMS_SMP)
376 _Assert( aggregation->Action.next == NULL );
378 aggregation->Action.node = node;
379 aggregation->Action.type = type;
382#if defined(RTEMS_SMP)
392#
if defined(RTEMS_DEBUG)
401 next = aggregation->Action.next;
402#if defined(RTEMS_DEBUG)
403 aggregation->Action.next = NULL;
419static inline bool _Priority_Less(
430 return *the_left < the_right->
priority;
446static inline bool _Priority_Plain_insert(
452 return _RBTree_Insert_inline(
468static inline void _Priority_Plain_extract(
485static inline void _Priority_Plain_changed(
490 _Priority_Plain_extract( aggregation, node );
491 _Priority_Plain_insert( aggregation, node, node->
priority );
494typedef void ( *Priority_Add_handler )(
500typedef void ( *Priority_Change_handler )(
507typedef void ( *Priority_Remove_handler )(
523static inline void _Priority_Change_nothing(
545static inline void _Priority_Remove_nothing(
569static inline void _Priority_Non_empty_insert(
573 Priority_Change_handler change,
579 _Assert( !_Priority_Is_empty( aggregation ) );
580 is_new_minimum = _Priority_Plain_insert( aggregation, node, node->
priority );
582 if ( is_new_minimum ) {
600static inline void _Priority_Insert(
604 Priority_Add_handler add,
605 Priority_Change_handler change,
609 if ( _Priority_Is_empty( aggregation ) ) {
610 _Priority_Initialize_one( aggregation, node );
611 ( *add )( aggregation, actions, arg );
613 _Priority_Non_empty_insert( aggregation, node, actions, change, arg );
634static inline void _Priority_Extract(
638 Priority_Remove_handler remove,
639 Priority_Change_handler change,
643 _Priority_Plain_extract( aggregation, node );
645 if ( _Priority_Is_empty( aggregation ) ) {
646 ( *remove )( aggregation, actions, arg );
651 min = _Priority_Get_minimum_node( aggregation );
654 if ( node->
priority < min->priority ) {
674static inline void _Priority_Extract_non_empty(
678 Priority_Change_handler change,
684 _Priority_Plain_extract( aggregation, node );
685 _Assert( !_Priority_Is_empty( aggregation ) );
687 min = _Priority_Get_minimum_node( aggregation );
689 if ( node->
priority < min->priority ) {
709static inline void _Priority_Changed(
714 Priority_Change_handler change,
720 _Priority_Plain_changed( aggregation, node );
726 min = _Priority_Get_minimum_node( aggregation );
731 ( *change )( aggregation, group_order, actions, arg );
745static inline void _Priority_Replace(
754 &victim->Node.RBTree,
755 &replacement->Node.RBTree
#define RTEMS_CONTAINER_OF(_m, _type, _member_name)
Gets the container of a member.
Definition basedefs.h:306
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG and static analysis runs.
Definition assert.h:96
uint64_t Priority_Control
The thread priority control.
Definition priority.h:91
Priority_Group_order
The priority group order determines if a priority node is inserted as the first or last node into its...
Definition priorityimpl.h:62
Priority_Action_type
The priority action type.
Definition priority.h:130
@ PRIORITY_GROUP_LAST
Priority group last option requests that the priority node is inserted as the last node into its prio...
Definition priorityimpl.h:73
@ PRIORITY_GROUP_FIRST
Priority group first option requests that the priority node is inserted as the first node into its pr...
Definition priorityimpl.h:67
void _RBTree_Extract(RBTree_Control *the_rbtree, RBTree_Node *the_node)
Extracts (removes) the node from the red-black tree.
Definition rbtreeextract.c:63
void _RBTree_Replace_node(RBTree_Control *the_rbtree, RBTree_Node *victim, RBTree_Node *replacement)
Replaces a node in the red-black tree without a rebalance.
Definition rbtreereplace.c:43
RBTree_Node * _RBTree_Minimum(const RBTree_Control *the_rbtree)
Returns the minimum node of the red-black tree.
Definition rbtreemin.c:43
const Scheduler_Control _Scheduler_Table[]
This table contains the configured schedulers.
This header file provides interfaces of the Priority Handler which are used by the implementation and...
This header file provides interfaces of the Scheduler Handler which are used by the implementation an...
A list of priority actions.
Definition priority.h:207
Priority_Aggregation * actions
The first action of a priority action list.
Definition priority.h:211
The priority aggregation.
Definition priority.h:147
Priority_Node Node
This priority node reflects the overall priority of the aggregation.
Definition priority.h:161
RBTree_Control Contributors
A red-black tree to contain priority nodes contributing to the overall priority of this priority aggr...
Definition priority.h:167
The priority node to build up a priority aggregation.
Definition priority.h:112
Priority_Control priority
The priority value of this node.
Definition priority.h:124
Red-black tree node.
Definition rbtree.h:73