diff options
author | Mark Johannes <Mark.Johannes@OARcorp.com> | 1996-08-07 20:57:28 +0000 |
---|---|---|
committer | Mark Johannes <Mark.Johannes@OARcorp.com> | 1996-08-07 20:57:28 +0000 |
commit | cc757febff3b60a3577925b15a14646255b7c996 (patch) | |
tree | bfdf50b4a1c92d9a98510ff0dd4ff44879ee0d32 /cpukit/score | |
parent | added complete test cases for pthread_attr_getschedparam, (diff) | |
download | rtems-cc757febff3b60a3577925b15a14646255b7c996.tar.bz2 |
_CORE_Mutex_seize: added checks for priority ceiling violation, also added
checks to ensure priority was not lowered.
Diffstat (limited to 'cpukit/score')
-rw-r--r-- | cpukit/score/src/coremutex.c | 30 |
1 files changed, 24 insertions, 6 deletions
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; } } |