Changeset 8f0529f in rtems


Ignore:
Timestamp:
Nov 2, 1999, 3:58:09 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
2cd5444
Parents:
9693fdac
Message:

Added maximum count detection logic.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/score/include/rtems/score/coresem.h

    r9693fdac r8f0529f  
    5656  CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT,
    5757  CORE_SEMAPHORE_WAS_DELETED,
    58   CORE_SEMAPHORE_TIMEOUT
     58  CORE_SEMAPHORE_TIMEOUT,
     59  CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
    5960}   CORE_semaphore_Status;
    6061
     
    6566
    6667typedef struct {
     68  unsigned32                  maximum_count;
    6769  CORE_semaphore_Disciplines  discipline;
    6870}   CORE_semaphore_Attributes;
  • c/src/exec/score/src/coresem.c

    r9693fdac r8f0529f  
    9292{
    9393  Thread_Control *the_thread;
     94  ISR_Level       level;
     95  CORE_semaphore_Status status;
     96
     97  status = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
    9498
    9599  if ( (the_thread = _Thread_queue_Dequeue(&the_semaphore->Wait_queue)) ) {
     
    98102      (*api_semaphore_mp_support) ( the_thread, id );
    99103
    100   } else
    101     the_semaphore->count += 1;
     104  } else {
     105    _ISR_Disable( level );
     106      if ( the_semaphore->count <= the_semaphore->Attributes.maximum_count )
     107        the_semaphore->count += 1;
     108      else
     109        status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED;
     110    _ISR_Enable( level );
     111  }
    102112
    103   return( CORE_SEMAPHORE_STATUS_SUCCESSFUL );
     113  return status;
    104114}
    105115
  • cpukit/score/include/rtems/score/coresem.h

    r9693fdac r8f0529f  
    5656  CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT,
    5757  CORE_SEMAPHORE_WAS_DELETED,
    58   CORE_SEMAPHORE_TIMEOUT
     58  CORE_SEMAPHORE_TIMEOUT,
     59  CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
    5960}   CORE_semaphore_Status;
    6061
     
    6566
    6667typedef struct {
     68  unsigned32                  maximum_count;
    6769  CORE_semaphore_Disciplines  discipline;
    6870}   CORE_semaphore_Attributes;
  • cpukit/score/src/coresem.c

    r9693fdac r8f0529f  
    9292{
    9393  Thread_Control *the_thread;
     94  ISR_Level       level;
     95  CORE_semaphore_Status status;
     96
     97  status = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
    9498
    9599  if ( (the_thread = _Thread_queue_Dequeue(&the_semaphore->Wait_queue)) ) {
     
    98102      (*api_semaphore_mp_support) ( the_thread, id );
    99103
    100   } else
    101     the_semaphore->count += 1;
     104  } else {
     105    _ISR_Disable( level );
     106      if ( the_semaphore->count <= the_semaphore->Attributes.maximum_count )
     107        the_semaphore->count += 1;
     108      else
     109        status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED;
     110    _ISR_Enable( level );
     111  }
    102112
    103   return( CORE_SEMAPHORE_STATUS_SUCCESSFUL );
     113  return status;
    104114}
    105115
Note: See TracChangeset for help on using the changeset viewer.