Changeset 3f72dda6 in rtems


Ignore:
Timestamp:
May 25, 2016, 6:37:28 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11
Children:
c6c4fce9
Parents:
276dfd9
git-author:
Sebastian Huber <sebastian.huber@…> (05/25/16 06:37:28)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/25/16 10:48:00)
Message:

posix: Fix pthread_spin_unlock() error status

Update #2719.

Files:
5 edited

Legend:

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

    r276dfd9 r3f72dda6  
    3232  -1,                       /* CORE_SPINLOCK_TIMEOUT */
    3333  EBUSY,                    /* CORE_SPINLOCK_IS_BUSY */
    34   EBUSY,                    /* CORE_SPINLOCK_UNAVAILABLE */
    35   0                         /* CORE_SPINLOCK_NOT_LOCKED */
     34  EBUSY                     /* CORE_SPINLOCK_UNAVAILABLE */
    3635};
    3736
  • cpukit/score/include/rtems/score/corespinlockimpl.h

    r276dfd9 r3f72dda6  
    5757   *  unavailable.
    5858   */
    59   CORE_SPINLOCK_UNAVAILABLE,
    60   /** This status indicates that the spinlock is not currently locked and thus
    61    *  should not be released.
    62    */
    63   CORE_SPINLOCK_NOT_LOCKED
     59  CORE_SPINLOCK_UNAVAILABLE
    6460}   CORE_spinlock_Status;
    6561
    6662/** This is a shorthand for the last status code. */
    67 #define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_NOT_LOCKED
     63#define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_UNAVAILABLE
    6864
    6965/** This indicates the lock is available. */
  • cpukit/score/src/corespinlockrelease.c

    r276dfd9 r3f72dda6  
    3333
    3434    /*
    35      *  It must locked before it can be unlocked.
    36      */
    37     if ( the_spinlock->lock == CORE_SPINLOCK_UNLOCKED ) {
    38       _ISR_Enable( level );
    39       return CORE_SPINLOCK_NOT_LOCKED;
    40     }
    41 
    42     /*
    4335     *  It must locked by the current thread before it can be unlocked.
    4436     */
    45     if ( the_spinlock->holder != _Thread_Executing->Object.id ) {
     37    if (
     38      the_spinlock->lock != CORE_SPINLOCK_LOCKED
     39        || the_spinlock->holder != _Thread_Executing
     40    ) {
    4641      _ISR_Enable( level );
    4742      return CORE_SPINLOCK_NOT_HOLDER;
  • testsuites/psxtests/psxspin01/psxspin01.scn

    r276dfd9 r3f72dda6  
    1 *** POSIX SPINLOCK TEST 01 ***
     1*** BEGIN OF TEST PSXSPIN 1 ***
    22pthread_spin_init( NULL, PTHREAD_PROCESS_PRIVATE ) -- EINVAL
    33pthread_spin_init( NULL, PTHREAD_PROCESS_SHARED ) -- EINVAL
     
    1515pthread_spin_unlock( &spinlock ) -- EINVAL
    1616pthread_spin_destroy( &spinlock ) -- EINVAL
    17 pthread_spin_unlock( &Spinlock ) -- already unlocked OK
     17pthread_spin_unlock( &Spinlock ) -- EPERM
    1818pthread_spin_lock( &Spinlock ) -- OK
    1919pthread_spin_lock( &Spinlock ) -- EDEADLK
     
    2424pthread_spin_lock( &Spinlock ) from Thread -- OK
    2525sleep to allow main thread to run
     26pthread_spin_unlock( &Spinlock ) -- EPERM
    2627pthread_spin_lock( &Spinlock ) -- OK
    2728pthread_spin_unlock( &Spinlock ) from Thread -- OK
     
    2930pthread_spin_unlock( &Spinlock ) -- OK
    3031pthread_spin_destroy( &Spinlock ) -- OK
    31 *** END OF POSIX SPINLOCK TEST 01 ***
     32*** END OF TEST PSXSPIN 1 ***
  • testsuites/psxtests/psxspin01/test.c

    r276dfd9 r3f72dda6  
    147147  rtems_test_assert( status == EINVAL );
    148148
    149   puts( "pthread_spin_unlock( &Spinlock ) -- already unlocked OK" );
    150   status = pthread_spin_unlock( &Spinlock );
    151   rtems_test_assert( status == 0 );
     149  puts( "pthread_spin_unlock( &Spinlock ) -- EPERM" );
     150  status = pthread_spin_unlock( &Spinlock );
     151  rtems_test_assert( status == EPERM );
    152152
    153153  /* Now some basic locking and unlocking with a deadlock verification */
     
    201201
    202202  mainThreadSpinning = 1;
     203
     204  puts( "pthread_spin_unlock( &Spinlock ) -- EPERM" );
     205  status = pthread_spin_unlock( &Spinlock );
     206  rtems_test_assert( status == EPERM );
     207
    203208  puts( "pthread_spin_lock( &Spinlock ) -- OK" );
    204209  status = pthread_spin_lock( &Spinlock );
Note: See TracChangeset for help on using the changeset viewer.