From 77ff5599e0d8e6d91190a379be21a332f83252b0 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 10 Jun 2016 08:48:54 +0200 Subject: 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. --- cpukit/posix/src/mutexsetprioceiling.c | 39 +++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'cpukit/posix/src/mutexsetprioceiling.c') 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 ); -- cgit v1.2.3