summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-06-28 06:54:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-09-08 09:55:28 +0200
commitb20b736382280fb522d176273645a7e955a97a60 (patch)
treebeb78ee50ef8b6a9257ecf5f8d276af35db11c5a /cpukit/score
parentscore: Add scheduler node implementation header (diff)
downloadrtems-b20b736382280fb522d176273645a7e955a97a60.tar.bz2
score: Introduce _Thread_Get_priority()
Avoid direct access to thread internal data fields.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/include/rtems/score/coremuteximpl.h2
-rw-r--r--cpukit/score/include/rtems/score/mrspimpl.h4
-rw-r--r--cpukit/score/include/rtems/score/schedulersimpleimpl.h6
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h18
-rw-r--r--cpukit/score/src/mpci.c2
-rw-r--r--cpukit/score/src/schedulercbsunblock.c8
-rw-r--r--cpukit/score/src/scheduleredfreleasejob.c4
-rw-r--r--cpukit/score/src/scheduleredfunblock.c2
-rw-r--r--cpukit/score/src/schedulerpriorityunblock.c2
-rw-r--r--cpukit/score/src/schedulersimpleunblock.c10
-rw-r--r--cpukit/score/src/threadchangepriority.c4
-rw-r--r--cpukit/score/src/threadqops.c4
-rw-r--r--cpukit/score/src/threadrestart.c4
-rw-r--r--cpukit/score/src/threadsetpriority.c2
14 files changed, 48 insertions, 24 deletions
diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h
index d40d91c4fd..25094a49df 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -393,7 +393,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Set_owner(
Per_CPU_Control *cpu_self;
priority_ceiling = the_mutex->priority_ceiling;
- current_priority = owner->current_priority;
+ current_priority = _Thread_Get_priority( owner );
if ( current_priority < priority_ceiling ) {
_CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context );
diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h
index 5f639d7e04..cc00aa3cfd 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -88,7 +88,7 @@ RTEMS_INLINE_ROUTINE bool _MRSP_Restore_priority_filter(
*new_priority
);
- return *new_priority != thread->current_priority;
+ return *new_priority != _Thread_Get_priority( thread );
}
RTEMS_INLINE_ROUTINE void _MRSP_Restore_priority(
@@ -325,7 +325,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize(
{
Status_Control status;
const Scheduler_Control *scheduler = _Scheduler_Get_own( executing );
- Priority_Control initial_priority = executing->current_priority;
+ Priority_Control initial_priority = _Thread_Get_priority( executing );
Priority_Control ceiling_priority = _MRSP_Get_priority( mrsp, scheduler );
bool priority_ok = !_Thread_Priority_less_than(
ceiling_priority,
diff --git a/cpukit/score/include/rtems/score/schedulersimpleimpl.h b/cpukit/score/include/rtems/score/schedulersimpleimpl.h
index b73a1b2c78..85951fa631 100644
--- a/cpukit/score/include/rtems/score/schedulersimpleimpl.h
+++ b/cpukit/score/include/rtems/score/schedulersimpleimpl.h
@@ -46,7 +46,8 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_lifo_order(
const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
const Thread_Control *thread_next = (const Thread_Control *) next;
- return thread_to_insert->current_priority <= thread_next->current_priority;
+ return _Thread_Get_priority( thread_to_insert )
+ <= _Thread_Get_priority( thread_next );
}
RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_fifo_order(
@@ -57,7 +58,8 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_fifo_order(
const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
const Thread_Control *thread_next = (const Thread_Control *) next;
- return thread_to_insert->current_priority < thread_next->current_priority;
+ return _Thread_Get_priority( thread_to_insert )
+ < _Thread_Get_priority( thread_next );
}
RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_lifo(
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index adb10cbd6f..1fce842533 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -930,6 +930,24 @@ RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources(
}
/**
+ * @brief Returns the priority of the thread.
+ *
+ * Returns the user API and thread wait information relevant thread priority.
+ * This includes temporary thread priority adjustments due to locking
+ * protocols, a job release or the POSIX sporadic server for example.
+ *
+ * @return The priority of the thread.
+ *
+ * @see _Scheduler_Node_get_priority().
+ */
+RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_priority(
+ const Thread_Control *the_thread
+)
+{
+ return the_thread->current_priority;
+}
+
+/**
* @brief Acquires the thread wait default lock inside a critical section
* (interrupts disabled).
*
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index 87d90a63f9..315b33d90f 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -240,7 +240,7 @@ Status_Control _MPCI_Send_request_packet(
executing = _Per_CPU_Get_executing( cpu_self );
the_packet->source_tid = executing->Object.id;
- the_packet->source_priority = executing->current_priority;
+ the_packet->source_priority = _Thread_Get_priority( executing );
the_packet->to_convert =
( the_packet->to_convert - sizeof(MP_packet_Prefix) ) / sizeof(uint32_t);
diff --git a/cpukit/score/src/schedulercbsunblock.c b/cpukit/score/src/schedulercbsunblock.c
index 70db651080..0c1e48ebed 100644
--- a/cpukit/score/src/schedulercbsunblock.c
+++ b/cpukit/score/src/schedulercbsunblock.c
@@ -61,8 +61,10 @@ Scheduler_Void_or_thread _Scheduler_CBS_Unblock(
the_thread->real_priority = priority;
if (
- _Thread_Priority_less_than( the_thread->current_priority, priority )
- || !_Thread_Owns_resources( the_thread )
+ _Thread_Priority_less_than(
+ _Thread_Get_priority( the_thread ),
+ priority
+ ) || !_Thread_Owns_resources( the_thread )
) {
the_thread->current_priority = priority;
}
@@ -84,7 +86,7 @@ Scheduler_Void_or_thread _Scheduler_CBS_Unblock(
* Even if the thread isn't preemptible, if the new heir is
* a pseudo-ISR system task, we need to do a context switch.
*/
- if ( priority < _Thread_Heir->current_priority ) {
+ if ( priority < _Thread_Get_priority( _Thread_Heir ) ) {
_Scheduler_Update_heir( the_thread, priority == PRIORITY_PSEUDO_ISR );
}
diff --git a/cpukit/score/src/scheduleredfreleasejob.c b/cpukit/score/src/scheduleredfreleasejob.c
index 0fbf0f0f61..4c74c48699 100644
--- a/cpukit/score/src/scheduleredfreleasejob.c
+++ b/cpukit/score/src/scheduleredfreleasejob.c
@@ -32,7 +32,7 @@ static bool _Scheduler_EDF_Release_job_filter(
node = _Scheduler_EDF_Thread_get_node( the_thread );
- current_priority = the_thread->current_priority;
+ current_priority = _Thread_Get_priority( the_thread );
new_priority = *new_priority_p;
node->current_priority = new_priority;
@@ -69,7 +69,7 @@ static bool _Scheduler_EDF_Cancel_job_filter(
node = _Scheduler_EDF_Thread_get_node( the_thread );
- current_priority = the_thread->current_priority;
+ current_priority = _Thread_Get_priority( the_thread );
new_priority = node->background_priority;
node->current_priority = new_priority;
diff --git a/cpukit/score/src/scheduleredfunblock.c b/cpukit/score/src/scheduleredfunblock.c
index 0f04cb3b2d..9b156eca46 100644
--- a/cpukit/score/src/scheduleredfunblock.c
+++ b/cpukit/score/src/scheduleredfunblock.c
@@ -52,7 +52,7 @@ Scheduler_Void_or_thread _Scheduler_EDF_Unblock(
* Even if the thread isn't preemptible, if the new heir is
* a pseudo-ISR system task, we need to do a context switch.
*/
- if ( priority < _Thread_Heir->current_priority ) {
+ if ( priority < _Thread_Get_priority( _Thread_Heir ) ) {
_Scheduler_Update_heir(
the_thread,
priority == ( SCHEDULER_EDF_PRIO_MSB | PRIORITY_PSEUDO_ISR )
diff --git a/cpukit/score/src/schedulerpriorityunblock.c b/cpukit/score/src/schedulerpriorityunblock.c
index 9fc266bbc6..7186103f2b 100644
--- a/cpukit/score/src/schedulerpriorityunblock.c
+++ b/cpukit/score/src/schedulerpriorityunblock.c
@@ -67,7 +67,7 @@ Scheduler_Void_or_thread _Scheduler_priority_Unblock (
* Even if the thread isn't preemptible, if the new heir is
* a pseudo-ISR system task, we need to do a context switch.
*/
- if ( priority < _Thread_Heir->current_priority ) {
+ if ( priority < _Thread_Get_priority( _Thread_Heir ) ) {
_Scheduler_Update_heir( the_thread, priority == PRIORITY_PSEUDO_ISR );
}
diff --git a/cpukit/score/src/schedulersimpleunblock.c b/cpukit/score/src/schedulersimpleunblock.c
index a020f74767..de08fc1a5a 100644
--- a/cpukit/score/src/schedulersimpleunblock.c
+++ b/cpukit/score/src/schedulersimpleunblock.c
@@ -26,10 +26,12 @@ Scheduler_Void_or_thread _Scheduler_simple_Unblock(
Thread_Control *the_thread
)
{
- Scheduler_simple_Context *context =
- _Scheduler_simple_Get_context( scheduler );
+ Scheduler_simple_Context *context;
+ Priority_Control priority;
+ context = _Scheduler_simple_Get_context( scheduler );
_Scheduler_simple_Insert_priority_fifo( &context->Ready, the_thread );
+ priority = _Thread_Get_priority( the_thread );
/*
* If the thread that was unblocked is more important than the heir,
@@ -43,10 +45,10 @@ Scheduler_Void_or_thread _Scheduler_simple_Unblock(
* Even if the thread isn't preemptible, if the new heir is
* a pseudo-ISR system task, we need to do a context switch.
*/
- if ( the_thread->current_priority < _Thread_Heir->current_priority ) {
+ if ( priority < _Thread_Get_priority( _Thread_Heir ) ) {
_Scheduler_Update_heir(
the_thread,
- the_thread->current_priority == PRIORITY_PSEUDO_ISR
+ priority == PRIORITY_PSEUDO_ISR
);
}
diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c
index 97e7950693..3429e1a88d 100644
--- a/cpukit/score/src/threadchangepriority.c
+++ b/cpukit/score/src/threadchangepriority.c
@@ -120,7 +120,7 @@ static bool _Thread_Raise_priority_filter(
)
{
return _Thread_Priority_less_than(
- the_thread->current_priority,
+ _Thread_Get_priority( the_thread ),
*new_priority
);
}
@@ -149,7 +149,7 @@ static bool _Thread_Restore_priority_filter(
the_thread->priority_restore_hint = false;
- return *new_priority != the_thread->current_priority;
+ return *new_priority != _Thread_Get_priority( the_thread );
}
void _Thread_Restore_priority( Thread_Control *the_thread )
diff --git a/cpukit/score/src/threadqops.c b/cpukit/score/src/threadqops.c
index 4177151fae..e20241d494 100644
--- a/cpukit/score/src/threadqops.c
+++ b/cpukit/score/src/threadqops.c
@@ -230,7 +230,7 @@ static bool _Thread_queue_Priority_less(
scheduler_node = SCHEDULER_NODE_OF_WAIT_RBTREE_NODE( right );
the_right = _Scheduler_Node_get_owner( scheduler_node );
- return *the_left < the_right->current_priority;
+ return *the_left < _Thread_Get_priority( the_right );
}
static void _Thread_queue_Priority_priority_change(
@@ -302,7 +302,7 @@ static void _Thread_queue_Priority_do_enqueue(
#endif
scheduler_node = _Scheduler_Thread_get_own_node( the_thread );
- current_priority = the_thread->current_priority;
+ current_priority = _Thread_Get_priority( the_thread );
_RBTree_Initialize_node( &scheduler_node->Wait.Node.RBTree );
_RBTree_Insert_inline(
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index e963c732a8..149882795c 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -62,7 +62,7 @@ static bool _Thread_Raise_real_priority_filter(
real_priority = the_thread->real_priority;
new_priority = *new_priority_ptr;
- current_priority = the_thread->current_priority;
+ current_priority = _Thread_Get_priority( the_thread );
new_priority = _Thread_Priority_highest( real_priority, new_priority );
*new_priority_ptr = new_priority;
@@ -507,7 +507,7 @@ void _Thread_Cancel(
);
cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
- priority = executing->current_priority;
+ priority = _Thread_Get_priority( executing );
if ( _States_Is_dormant( the_thread->current_state ) ) {
_Thread_State_release( the_thread, &lock_context );
diff --git a/cpukit/score/src/threadsetpriority.c b/cpukit/score/src/threadsetpriority.c
index f6a061a281..d6b8319970 100644
--- a/cpukit/score/src/threadsetpriority.c
+++ b/cpukit/score/src/threadsetpriority.c
@@ -30,7 +30,7 @@ static bool _Thread_Set_priority_filter(
Priority_Control new_priority;
Priority_Control *old_priority_ptr;
- current_priority = the_thread->current_priority;
+ current_priority = _Thread_Get_priority( the_thread );
new_priority = *new_priority_ptr;
old_priority_ptr = arg;