From cc757febff3b60a3577925b15a14646255b7c996 Mon Sep 17 00:00:00 2001 From: Mark Johannes Date: Wed, 7 Aug 1996 20:57:28 +0000 Subject: _CORE_Mutex_seize: added checks for priority ceiling violation, also added checks to ensure priority was not lowered. --- cpukit/score/src/coremutex.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'cpukit/score/src') diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c index a5a27d8d34..b7b4b317df 100644 --- a/cpukit/score/src/coremutex.c +++ b/cpukit/score/src/coremutex.c @@ -110,6 +110,18 @@ void _CORE_mutex_Seize( ISR_Level level; executing = _Thread_Executing; + switch ( the_mutex->Attributes.discipline ) { + case CORE_MUTEX_DISCIPLINES_FIFO: + case CORE_MUTEX_DISCIPLINES_PRIORITY: + case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: + break; + case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: + if ( executing->current_priority < + the_mutex->Attributes.priority_ceiling) { + executing->Wait.return_code = CORE_MUTEX_STATUS_CEILING_VIOLATED; + return; + } + } executing->Wait.return_code = CORE_MUTEX_STATUS_SUCCESSFUL; _ISR_Disable( level ); if ( ! _CORE_mutex_Is_locked( the_mutex ) ) { @@ -123,13 +135,16 @@ void _CORE_mutex_Seize( case CORE_MUTEX_DISCIPLINES_FIFO: case CORE_MUTEX_DISCIPLINES_PRIORITY: case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: + /* already the highest priority */ break; case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: + if ( the_mutex->Attributes.priority_ceiling < + executing->current_priority ) { _Thread_Change_priority( - executing, + the_mutex->holder, the_mutex->Attributes.priority_ceiling ); - break; + } } return; } @@ -180,10 +195,13 @@ void _CORE_mutex_Seize( case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: break; case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: - _Thread_Change_priority( - executing, - the_mutex->Attributes.priority_ceiling - ); + if ( the_mutex->Attributes.priority_ceiling < + executing->current_priority ) { + _Thread_Change_priority( + executing, + the_mutex->Attributes.priority_ceiling + ); + }; break; } } -- cgit v1.2.3