[PATCH 4/4] score: Use Resource Handler for MrsP semaphores

Gedare Bloom gedare at rtems.org
Mon Jun 2 13:17:07 UTC 2014


>> @@ -200,27 +250,36 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Obtain(
>>    MRSP_Status status;
>>    const Scheduler_Control *scheduler = _Scheduler_Get( executing );
>>    uint32_t scheduler_index = _Scheduler_Get_index( scheduler );
>> +  Priority_Control initial_priority = executing->current_priority;
>>    Priority_Control ceiling_priority =
>>      _MRSP_Get_ceiling_priority( mrsp, scheduler_index );
>>    bool priority_ok = !_Scheduler_Is_priority_higher_than(
>>      scheduler,
>> -    executing->current_priority,
>> +    initial_priority,
>>      ceiling_priority
>>    );
>> +  Resource_Node *owner = _Resource_Get_owner( &mrsp->Resource );
> I'd put this after the priority_ok check, for better readability by
> keeping the error check closer to the cause. (Ahem, this should
> probably be in our conventions too, eh?)
>
>>
>>    if ( !priority_ok) {
>>      return MRSP_INVALID_PRIORITY;
>>    }
>>
I guess I wasn't clear, I meant you should do owner =
_Resource_Get_owner() here. e.g.
-----
Resource_Node *owner;
bool priority_ok = !_Scheduler_Is_priority_higher_than(
      scheduler,
      initial_priority,
      ceiling_priority
    );
 if ( !priority_ok) {
   return MRSP_INVALID_PRIORITY;
 }
 owner = _Resource_Get_owner( &mrsp->Resource );
-----

Also, at one point in time we discussed about a rule of not having
function calls in variable initialization. I will look if that is an
actual convention or not, but it would make this code easier to read.

-Gedare



More information about the devel mailing list