Changeset 39bcf741 in rtems


Ignore:
Timestamp:
May 25, 2016, 12:23:48 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
d887c1b
Parents:
dbedcf9
git-author:
Sebastian Huber <sebastian.huber@…> (05/25/16 12:23:48)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/26/16 19:44:30)
Message:

Fix semaphore post overflow status

Close #2720.

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/semaphoretranslatereturncode.c

    rdbedcf9 r39bcf741  
    2828  EINVAL,              /* CORE_SEMAPHORE_WAS_DELETED */
    2929  ETIMEDOUT,           /* CORE_SEMAPHORE_TIMEOUT */
    30   /* The next error can not occur since we set the maximum
    31    * count to the largest value the count can hold.
    32    */
    33   ENOSYS,              /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */
     30  EOVERFLOW            /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */
    3431};
  • cpukit/posix/src/sempost.c

    rdbedcf9 r39bcf741  
    2020
    2121#include <semaphore.h>
     22#include <limits.h>
    2223
    2324#include <rtems/posix/semaphoreimpl.h>
     
    2930  POSIX_Semaphore_Control *the_semaphore;
    3031  Thread_queue_Context     queue_context;
     32  CORE_semaphore_Status    status;
    3133
    3234  the_semaphore = _POSIX_Semaphore_Get( sem, &queue_context );
     
    3638  }
    3739
    38   _CORE_semaphore_Surrender(
     40  status = _CORE_semaphore_Surrender(
    3941    &the_semaphore->Semaphore,
     42    SEM_VALUE_MAX,
    4043    &queue_context
    4144  );
    42   return 0;
     45
     46  if ( status == CORE_SEMAPHORE_STATUS_SUCCESSFUL ) {
     47    return 0;
     48  }
     49
     50  rtems_set_errno_and_return_minus_one(
     51    _POSIX_Semaphore_Translate_core_semaphore_return_code( status )
     52  );
    4353}
  • cpukit/rtems/src/semrelease.c

    rdbedcf9 r39bcf741  
    6969    semaphore_status = _CORE_semaphore_Surrender(
    7070      &the_semaphore->Core_control.semaphore,
     71      UINT32_MAX,
    7172      &queue_context
    7273    );
  • cpukit/rtems/src/semtranslatereturncode.c

    rdbedcf9 r39bcf741  
    3838  RTEMS_OBJECT_WAS_DELETED, /* CORE_SEMAPHORE_WAS_DELETED */
    3939  RTEMS_TIMEOUT,            /* CORE_SEMAPHORE_TIMEOUT  */
    40   RTEMS_INTERNAL_ERROR,     /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */
     40  RTEMS_UNSATISFIED         /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */
    4141};
  • cpukit/score/include/rtems/score/coresemimpl.h

    rdbedcf9 r39bcf741  
    150150RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender(
    151151  CORE_semaphore_Control  *the_semaphore,
     152  uint32_t                 maximum_count,
    152153  Thread_queue_Context    *queue_context
    153154)
     
    172173    );
    173174  } else {
    174     if ( the_semaphore->count < UINT32_MAX )
     175    if ( the_semaphore->count < maximum_count )
    175176      the_semaphore->count += 1;
    176177    else
  • cpukit/score/src/mpci.c

    rdbedcf9 r39bcf741  
    375375
    376376  _ISR_lock_ISR_disable( &queue_context.Lock_context );
    377   (void) _CORE_semaphore_Surrender( &_MPCI_Semaphore, &queue_context );
     377  (void) _CORE_semaphore_Surrender( &_MPCI_Semaphore, UINT32_MAX, &queue_context );
    378378}
    379379
  • testsuites/psxtests/psxsem01/init.c

    rdbedcf9 r39bcf741  
    1616#include <errno.h>
    1717#include <fcntl.h>
     18#include <limits.h>
    1819#include <time.h>
    1920#include <tmacros.h>
     
    7576  eno = pthread_join( th, NULL );
    7677  rtems_test_assert( eno == 0 );
     78}
     79
     80static void test_sem_post_overflow(void)
     81{
     82  sem_t sem;
     83  int   rv;
     84  int   val;
     85
     86  rv = sem_init( &sem, 0, SEM_VALUE_MAX );
     87  rtems_test_assert( rv == 0 );
     88
     89  rv = sem_getvalue( &sem, &val );
     90  rtems_test_assert( rv == 0 );
     91  rtems_test_assert( val == (int) SEM_VALUE_MAX );
     92
     93  errno = 0;
     94  rv = sem_post( &sem );
     95  rtems_test_assert( rv == -1 );
     96  rtems_test_assert( errno == EOVERFLOW );
     97
     98  rv = sem_getvalue( &sem, &val );
     99  rtems_test_assert( rv == 0 );
     100  rtems_test_assert( val == (int) SEM_VALUE_MAX );
     101
     102  rv = sem_wait( &sem );
     103  rtems_test_assert( rv == 0 );
     104
     105  rv = sem_post( &sem );
     106  rtems_test_assert( rv == 0 );
     107
     108  rv = sem_destroy( &sem );
     109  rtems_test_assert( rv == 0 );
    77110}
    78111
     
    346379
    347380  test_sem_wait_during_delete();
     381  test_sem_post_overflow();
    348382
    349383  /* Try adding in unlinking before closing... (can we still open?) */
  • testsuites/sptests/spsem_err01/init.c

    rdbedcf9 r39bcf741  
    3030  Semaphore_name[ 2 ]  =  rtems_build_name( 'S', 'M', '2', ' ' );
    3131  Semaphore_name[ 3 ]  =  rtems_build_name( 'S', 'M', '3', ' ' );
     32
     33  /* release overflow */
     34  status = rtems_semaphore_create(
     35    Semaphore_name[ 1 ],
     36    UINT32_MAX,
     37    RTEMS_COUNTING_SEMAPHORE,
     38    0,
     39    &Semaphore_id[ 1 ]
     40  );
     41  fatal_directive_status(
     42    status,
     43    RTEMS_SUCCESSFUL,
     44    "rtems_semaphore_create"
     45  );
     46  puts( "TA1 - rtems_semaphore_create - RTEMS_SUCCESSFUL" );
     47  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
     48  fatal_directive_status(
     49    status,
     50    RTEMS_UNSATISFIED,
     51    "rtems_semaphore_release"
     52  );
     53  puts( "TA1 - rtems_semaphore_release - RTEMS_UNSATISFIED" );
     54  status = rtems_semaphore_delete( Semaphore_id[ 1 ] );
     55  fatal_directive_status(
     56    status,
     57    RTEMS_SUCCESSFUL,
     58    "rtems_semaphore_delete"
     59  );
     60  puts( "TA1 - rtems_semaphore_delete - RTEMS_SUCCESSFUL" );
    3261
    3362  /* invalid name */
  • testsuites/sptests/spsem_err01/spsem_err01.scn

    rdbedcf9 r39bcf741  
    1 *** TEST SEMAPHORE ERROR 01 ***
     1*** BEGIN OF TEST SP SEMAPHORE ERROR 01 ***
     2TA1 - rtems_semaphore_create - RTEMS_SUCCESSFUL
     3TA1 - rtems_semaphore_release - RTEMS_UNSATISFIED
     4TA1 - rtems_semaphore_delete - RTEMS_SUCCESSFUL
    25TA1 - rtems_semaphore_create - RTEMS_INVALID_NAME
    36TA1 - rtems_semaphore_create - RTEMS_INVALID_ADDRESS
     
    1720TA1 - rtems_semaphore_release - RTEMS_INVALID_ID
    1821TA1 - rtems_semaphore_flush - RTEMS_INVALID_ID
    19 *** END TEST SEMAPHORE ERROR 01 ***
     22*** END OF TEST SP SEMAPHORE ERROR 01 ***
Note: See TracChangeset for help on using the changeset viewer.