score: Use constant for maximum count of CORE sema

This commit is contained in:
Sebastian Huber
2016-03-22 08:52:50 +01:00
parent 1e1a91ed11
commit 97bbf028e6
7 changed files with 3 additions and 27 deletions

View File

@@ -28,11 +28,8 @@ rtems_monitor_sema_canonical(
if (_Attributes_Is_counting_semaphore(canonical_sema->attribute)) { if (_Attributes_Is_counting_semaphore(canonical_sema->attribute)) {
/* we have a counting semaphore */ /* we have a counting semaphore */
canonical_sema->cur_count = canonical_sema->cur_count = rtems_sema->Core_control.semaphore.count;
rtems_sema->Core_control.semaphore.count; canonical_sema->max_count = UINT32_MAX;
canonical_sema->max_count =
rtems_sema->Core_control.semaphore.Attributes.maximum_count;
} }
else { else {
/* we have a binary semaphore (mutex) */ /* we have a binary semaphore (mutex) */

View File

@@ -95,7 +95,6 @@ int _POSIX_Semaphore_Create_support(
_CORE_semaphore_Initialize( _CORE_semaphore_Initialize(
&the_semaphore->Semaphore, &the_semaphore->Semaphore,
CORE_SEMAPHORE_DISCIPLINES_FIFO, CORE_SEMAPHORE_DISCIPLINES_FIFO,
0xFFFFFFFF,
value value
); );

View File

@@ -153,7 +153,6 @@ rtems_status_code rtems_semaphore_create(
_CORE_semaphore_Initialize( _CORE_semaphore_Initialize(
&the_semaphore->Core_control.semaphore, &the_semaphore->Core_control.semaphore,
semaphore_discipline, semaphore_discipline,
0xFFFFFFFF,
count count
); );
#if defined(RTEMS_SMP) #if defined(RTEMS_SMP)

View File

@@ -49,15 +49,6 @@ typedef enum {
CORE_SEMAPHORE_DISCIPLINES_PRIORITY CORE_SEMAPHORE_DISCIPLINES_PRIORITY
} CORE_semaphore_Disciplines; } CORE_semaphore_Disciplines;
/**
* The following defines the control block used to manage the
* attributes of each semaphore.
*/
typedef struct {
/** This element indicates the maximum count this semaphore may have. */
uint32_t maximum_count;
} CORE_semaphore_Attributes;
/** /**
* The following defines the control block used to manage each * The following defines the control block used to manage each
* counting semaphore. * counting semaphore.
@@ -73,10 +64,6 @@ typedef struct {
*/ */
const Thread_queue_Operations *operations; const Thread_queue_Operations *operations;
/** This element is the set of attributes which define this instance's
* behavior.
*/
CORE_semaphore_Attributes Attributes;
/** This element contains the current count of this semaphore. */ /** This element contains the current count of this semaphore. */
uint32_t count; uint32_t count;
} CORE_semaphore_Control; } CORE_semaphore_Control;

View File

@@ -87,13 +87,11 @@ typedef void ( *CORE_semaphore_API_mp_support_callout )(
* *
* @param[in] the_semaphore is the semaphore to initialize * @param[in] the_semaphore is the semaphore to initialize
* @param[in] discipline the blocking discipline * @param[in] discipline the blocking discipline
* @param[in] maximum_count the maximum count
* @param[in] initial_value is the initial count of the semaphore * @param[in] initial_value is the initial count of the semaphore
*/ */
void _CORE_semaphore_Initialize( void _CORE_semaphore_Initialize(
CORE_semaphore_Control *the_semaphore, CORE_semaphore_Control *the_semaphore,
CORE_semaphore_Disciplines discipline, CORE_semaphore_Disciplines discipline,
uint32_t maximum_count,
uint32_t initial_value uint32_t initial_value
); );
@@ -158,7 +156,7 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender(
_Thread_Dispatch_enable( _Per_CPU_Get() ); _Thread_Dispatch_enable( _Per_CPU_Get() );
#endif #endif
} else { } else {
if ( the_semaphore->count < the_semaphore->Attributes.maximum_count ) if ( the_semaphore->count < UINT32_MAX )
the_semaphore->count += 1; the_semaphore->count += 1;
else else
status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED; status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED;

View File

@@ -23,12 +23,9 @@
void _CORE_semaphore_Initialize( void _CORE_semaphore_Initialize(
CORE_semaphore_Control *the_semaphore, CORE_semaphore_Control *the_semaphore,
CORE_semaphore_Disciplines discipline, CORE_semaphore_Disciplines discipline,
uint32_t maximum_count,
uint32_t initial_value uint32_t initial_value
) )
{ {
the_semaphore->Attributes.maximum_count = maximum_count;
the_semaphore->count = initial_value; the_semaphore->count = initial_value;
_Thread_queue_Initialize( &the_semaphore->Wait_queue ); _Thread_queue_Initialize( &the_semaphore->Wait_queue );

View File

@@ -120,7 +120,6 @@ static void _MPCI_Handler_initialization( void )
_CORE_semaphore_Initialize( _CORE_semaphore_Initialize(
&_MPCI_Semaphore, &_MPCI_Semaphore,
CORE_SEMAPHORE_DISCIPLINES_FIFO, CORE_SEMAPHORE_DISCIPLINES_FIFO,
0xffffffff,
0 /* initial_value */ 0 /* initial_value */
); );
} }