RTEMS
schedulerprioritychangepriority.c
Go to the documentation of this file.
1 
9 /*
10  * COPYRIGHT (c) 2011.
11  * On-Line Applications Research Corporation (OAR).
12  *
13  * The license and distribution terms for this file may be
14  * found in the file LICENSE in this distribution or at
15  * http://www.rtems.org/license/LICENSE.
16  */
17 
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
23 
25  const Scheduler_Control *scheduler,
26  Thread_Control *the_thread,
27  Scheduler_Node *node
28 )
29 {
31  Scheduler_priority_Node *the_node;
32  unsigned int new_priority;
33  unsigned int unmapped_priority;
34 
35  if ( !_Thread_Is_ready( the_thread ) ) {
36  /* Nothing to do */
37  return;
38  }
39 
40  the_node = _Scheduler_priority_Node_downcast( node );
41  new_priority = (unsigned int)
42  _Scheduler_Node_get_priority( &the_node->Base );
43  unmapped_priority = SCHEDULER_PRIORITY_UNMAP( new_priority );
44 
45  if ( unmapped_priority == the_node->Ready_queue.current_priority ) {
46  /* Nothing to do */
47  return;
48  }
49 
50  context = _Scheduler_priority_Get_context( scheduler );
51 
53  &the_thread->Object.Node,
54  &the_node->Ready_queue,
55  &context->Bit_map
56  );
57 
59  &the_node->Ready_queue,
60  unmapped_priority,
61  &context->Bit_map,
62  &context->Ready[ 0 ]
63  );
64 
65  if ( SCHEDULER_PRIORITY_IS_APPEND( new_priority ) ) {
67  &the_thread->Object.Node,
68  &the_node->Ready_queue,
69  &context->Bit_map
70  );
71  } else {
73  &the_thread->Object.Node,
74  &the_node->Ready_queue,
75  &context->Bit_map
76  );
77  }
78 
79  _Scheduler_priority_Schedule_body( scheduler, the_thread, false );
80 }
#define SCHEDULER_PRIORITY_IS_APPEND(priority)
Returns true, if the item should be appended to its priority group, otherwise returns false and the i...
Chain_Control Ready[0]
One ready queue per priority level.
void _Scheduler_priority_Update_priority(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Updates the priority of the node.
static __inline__ void _Scheduler_priority_Ready_queue_enqueue(Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map)
Enqueues a node on the specified ready queue.
Scheduler_Node Base
Basic scheduler node.
unsigned int current_priority
The thread priority currently used by the scheduler.
static __inline__ Scheduler_priority_Context * _Scheduler_priority_Get_context(const Scheduler_Control *scheduler)
Gets the context of the scheduler.
Inlined Routines Associated with the Manipulation of the Priority-Based Scheduling Structures...
static __inline__ Priority_Control _Scheduler_Node_get_priority(Scheduler_Node *node)
Gets the priority of the node.
static __inline__ void _Scheduler_priority_Ready_queue_update(Scheduler_priority_Ready_queue *ready_queue, unsigned int new_priority, Priority_bit_map_Control *bit_map, Chain_Control *ready_queues)
Updates the specified ready queue data according to the new priority value.
Priority_bit_map_Control Bit_map
Bit map to indicate non-empty ready queues.
Scheduler_priority_Ready_queue Ready_queue
The associated ready queue of this node.
Chain_Node Node
Definition: objectdata.h:41
static __inline__ Scheduler_priority_Node * _Scheduler_priority_Node_downcast(Scheduler_Node *node)
Gets the priority node of the scheduler node.
Objects_Control Object
Definition: thread.h:727
static __inline__ void _Scheduler_priority_Ready_queue_enqueue_first(Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map)
Enqueues a node on the specified ready queue as first.
#define SCHEDULER_PRIORITY_UNMAP(priority)
Returns the plain priority value.
Scheduler node specialization for Deterministic Priority schedulers.
static __inline__ void _Scheduler_priority_Schedule_body(const Scheduler_Control *scheduler, Thread_Control *the_thread, bool force_dispatch)
Scheduling decision logic.
Scheduler control.
Definition: scheduler.h:264
Scheduler node for per-thread data.
Definition: schedulernode.h:79
static __inline__ bool _Thread_Is_ready(const Thread_Control *the_thread)
Checks if the thread is ready.
Definition: threadimpl.h:401
static __inline__ void _Scheduler_priority_Ready_queue_extract(Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map)
Extracts a node from the specified ready queue.