summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/mutexsetprioceiling.c
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/src/mutexsetprioceiling.c
parentscore: Delete unused _Scheduler_Priority_compare() (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/src/mutexsetprioceiling.c')
-rw-r--r--cpukit/posix/src/mutexsetprioceiling.c39
1 files changed, 22 insertions, 17 deletions
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 );