summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-06-10 08:48:54 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-06-22 14:36:40 +0200
commit77ff5599e0d8e6d91190a379be21a332f83252b0 (patch)
tree339e28b236beb9e606322cb801d7340e2e44f8bf /cpukit/posix
parentb8f76fa28e1e7258fbf9b15894fbf1be5b1fbe15 (diff)
downloadrtems-77ff5599e0d8e6d91190a379be21a332f83252b0.tar.bz2
score: Introduce map priority scheduler operation
Introduce map/unmap priority scheduler operations to map thread priority values from/to the user domain to/from the scheduler domain. Use the map priority operation to validate the thread priority. The EDF schedulers use this new operation to distinguish between normal priorities and priorities obtain through a job release. Update #2173. Update #2556.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/include/rtems/posix/priorityimpl.h7
-rw-r--r--cpukit/posix/src/mutexgetprioceiling.c12
-rw-r--r--cpukit/posix/src/mutexinit.c9
-rw-r--r--cpukit/posix/src/mutexsetprioceiling.c39
-rw-r--r--cpukit/posix/src/psxpriorityisvalid.c13
-rw-r--r--cpukit/posix/src/pthreadcreate.c3
6 files changed, 48 insertions, 35 deletions
diff --git a/cpukit/posix/include/rtems/posix/priorityimpl.h b/cpukit/posix/include/rtems/posix/priorityimpl.h
index ae2e763fba..b986d64cd5 100644
--- a/cpukit/posix/include/rtems/posix/priorityimpl.h
+++ b/cpukit/posix/include/rtems/posix/priorityimpl.h
@@ -88,13 +88,10 @@ Priority_Control _POSIX_Priority_To_core(
*
* @return The corresponding POSIX API priority.
*/
-RTEMS_INLINE_ROUTINE int _POSIX_Priority_From_core(
+int _POSIX_Priority_From_core(
const Scheduler_Control *scheduler,
Priority_Control priority
-)
-{
- return (int) ( scheduler->maximum_priority - priority );
-}
+);
/** @} */
diff --git a/cpukit/posix/src/mutexgetprioceiling.c b/cpukit/posix/src/mutexgetprioceiling.c
index eda02cba83..dfff98f9b7 100644
--- a/cpukit/posix/src/mutexgetprioceiling.c
+++ b/cpukit/posix/src/mutexgetprioceiling.c
@@ -45,10 +45,14 @@ int pthread_mutex_getprioceiling(
_POSIX_Mutex_Acquire_critical( the_mutex, &queue_context );
- *prioceiling = _POSIX_Priority_From_core(
- &_Scheduler_Table[ 0 ],
- the_mutex->Mutex.priority_ceiling
- );
+ if ( the_mutex->protocol == POSIX_MUTEX_PRIORITY_CEILING ) {
+ *prioceiling = _POSIX_Priority_From_core(
+ _CORE_ceiling_mutex_Get_scheduler( &the_mutex->Mutex ),
+ _CORE_ceiling_mutex_Get_priority( &the_mutex->Mutex )
+ );
+ } else {
+ *prioceiling = 0;
+ }
_POSIX_Mutex_Release( the_mutex, &queue_context );
diff --git a/cpukit/posix/src/mutexinit.c b/cpukit/posix/src/mutexinit.c
index 2cda90ea05..0dacc3fa03 100644
--- a/cpukit/posix/src/mutexinit.c
+++ b/cpukit/posix/src/mutexinit.c
@@ -135,19 +135,14 @@ int pthread_mutex_init(
switch ( protocol ) {
case POSIX_MUTEX_PRIORITY_CEILING:
- _CORE_ceiling_mutex_Initialize(
- &the_mutex->Mutex,
- priority
- );
+ _CORE_ceiling_mutex_Initialize( &the_mutex->Mutex, scheduler, priority );
break;
default:
_Assert(
the_mutex->protocol == POSIX_MUTEX_NO_PROTOCOL
|| the_mutex->protocol == POSIX_MUTEX_PRIORITY_INHERIT
);
- _CORE_recursive_mutex_Initialize(
- &the_mutex->Mutex.Recursive
- );
+ _CORE_recursive_mutex_Initialize( &the_mutex->Mutex.Recursive );
break;
}
diff --git a/cpukit/posix/src/mutexsetprioceiling.c b/cpukit/posix/src/mutexsetprioceiling.c
index 478aafa6e0..31e54c5fc3 100644
--- a/cpukit/posix/src/mutexsetprioceiling.c
+++ b/cpukit/posix/src/mutexsetprioceiling.c
@@ -31,15 +31,13 @@ int pthread_mutex_setprioceiling(
int *old_ceiling
)
{
- POSIX_Mutex_Control *the_mutex;
- const Scheduler_Control *scheduler;
- bool valid;
- Priority_Control priority;
- int error;
- int unlock_error;
+ POSIX_Mutex_Control *the_mutex;
+ int error;
+ int unlock_error;
- if ( !old_ceiling )
+ if ( old_ceiling == NULL ) {
return EINVAL;
+ }
/*
* Must acquire the mutex before we can change it's ceiling.
@@ -54,19 +52,26 @@ int pthread_mutex_setprioceiling(
the_mutex = _POSIX_Mutex_Get_no_protection( mutex );
_Assert( the_mutex != NULL );
- scheduler = &_Scheduler_Table[ 0 ];
+ if ( the_mutex->protocol == POSIX_MUTEX_PRIORITY_CEILING ) {
+ const Scheduler_Control *scheduler;
+ bool valid;
+ Priority_Control new_priority;
+ Priority_Control old_priority;
- *old_ceiling = _POSIX_Priority_From_core(
- scheduler,
- the_mutex->Mutex.priority_ceiling
- );
+ scheduler = _CORE_ceiling_mutex_Get_scheduler( &the_mutex->Mutex );
+ old_priority = _CORE_ceiling_mutex_Get_priority( &the_mutex->Mutex );
+ *old_ceiling = _POSIX_Priority_From_core( scheduler, old_priority );
- priority = _POSIX_Priority_To_core( scheduler, prioceiling, &valid );
- if ( valid ) {
- the_mutex->Mutex.priority_ceiling = priority;
- error = 0;
+ new_priority = _POSIX_Priority_To_core( scheduler, prioceiling, &valid );
+ if ( valid ) {
+ _CORE_ceiling_mutex_Set_priority( &the_mutex->Mutex, new_priority );
+ error = 0;
+ } else {
+ error = EINVAL;
+ }
} else {
- error = EINVAL;
+ *old_ceiling = 0;
+ error = 0;
}
unlock_error = pthread_mutex_unlock( mutex );
diff --git a/cpukit/posix/src/psxpriorityisvalid.c b/cpukit/posix/src/psxpriorityisvalid.c
index 22c4ac0b87..7c2300b4d6 100644
--- a/cpukit/posix/src/psxpriorityisvalid.c
+++ b/cpukit/posix/src/psxpriorityisvalid.c
@@ -19,6 +19,7 @@
#endif
#include <rtems/posix/priorityimpl.h>
+#include <rtems/score/schedulerimpl.h>
int _POSIX_Priority_Get_maximum( const Scheduler_Control *scheduler )
{
@@ -44,5 +45,15 @@ Priority_Control _POSIX_Priority_To_core(
*valid = ( posix_priority >= POSIX_SCHEDULER_MINIMUM_PRIORITY
&& core_posix_priority < scheduler->maximum_priority );
- return core_priority;
+ return _Scheduler_Map_priority( scheduler, core_priority );
+}
+
+int _POSIX_Priority_From_core(
+ const Scheduler_Control *scheduler,
+ Priority_Control core_priority
+)
+{
+ core_priority = _Scheduler_Unmap_priority( scheduler, core_priority );
+
+ return (int) ( scheduler->maximum_priority - core_priority );
}
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index b266a4cd7f..54b6a71040 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -103,6 +103,7 @@ int pthread_create(
#endif
executing = _Thread_Get_executing();
+ scheduler = _Scheduler_Get_own( executing );
/*
* P1003.1c/Draft 10, p. 121.
@@ -197,7 +198,7 @@ int pthread_create(
status = _Thread_Initialize(
&_POSIX_Threads_Information,
the_thread,
- _Scheduler_Get( executing ),
+ scheduler,
the_attr->stackaddr,
_POSIX_Threads_Ensure_minimum_stack(the_attr->stacksize),
is_fp,