Changeset 44f3ea9 in rtems


Ignore:
Timestamp:
Aug 31, 2015, 11:37:52 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
d9d0a84
Parents:
95b43d0
git-author:
Sebastian Huber <sebastian.huber@…> (08/31/15 11:37:52)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/01/15 10:50:56)
Message:

score: Fix return status of mutex try acquire

This fixes a copy and paste error (from libbsd).

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/src/mutex.c

    r95b43d0 r44f3ea9  
    269269  Thread_Control   *executing;
    270270  Thread_Control   *owner;
    271   int               success;
     271  int               eno;
    272272
    273273  mutex = _Mutex_Get( _mutex );
     
    279279    mutex->owner = executing;
    280280    ++executing->resource_count;
    281     success = 1;
    282   } else {
    283     success = 0;
     281    eno = 0;
     282  } else {
     283    eno = EBUSY;
    284284  }
    285285
    286286  _Mutex_Queue_release( mutex, &lock_context );
    287287
    288   return success;
     288  return eno;
    289289}
    290290
     
    394394  Thread_Control          *executing;
    395395  Thread_Control          *owner;
    396   int success;
     396  int                      eno;
    397397
    398398  mutex = _Mutex_recursive_Get( _mutex );
     
    404404    mutex->Mutex.owner = executing;
    405405    ++executing->resource_count;
    406     success = 1;
     406    eno = 0;
    407407  } else if ( owner == executing ) {
    408408    ++mutex->nest_level;
    409     success = 1;
    410   } else {
    411     success = 0;
     409    eno = 0;
     410  } else {
     411    eno = EBUSY;
    412412  }
    413413
    414414  _Mutex_Queue_release( &mutex->Mutex, &lock_context );
    415415
    416   return success;
     416  return eno;
    417417}
    418418
  • testsuites/sptests/spsyslock01/init.c

    r95b43d0 r44f3ea9  
    126126  struct _Mutex_Control *mtx = &ctx->mtx;
    127127  size_t idx = 0;
    128   int success;
    129 
    130   success = _Mutex_Try_acquire(mtx);
    131   rtems_test_assert(success == 1);
    132 
    133   success = _Mutex_Try_acquire(mtx);
    134   rtems_test_assert(success == 0);
     128  int eno;
     129
     130  eno = _Mutex_Try_acquire(mtx);
     131  rtems_test_assert(eno == 0);
     132
     133  eno = _Mutex_Try_acquire(mtx);
     134  rtems_test_assert(eno == EBUSY);
    135135
    136136  _Mutex_Release(mtx);
    137137
    138   success = _Mutex_Try_acquire(mtx);
    139   rtems_test_assert(success == 1);
     138  eno = _Mutex_Try_acquire(mtx);
     139  rtems_test_assert(eno == 0);
    140140
    141141  _Mutex_Release(mtx);
     
    143143  _Mutex_Acquire(mtx);
    144144
    145   success = _Mutex_Try_acquire(mtx);
    146   rtems_test_assert(success == 0);
     145  eno = _Mutex_Try_acquire(mtx);
     146  rtems_test_assert(eno == EBUSY);
    147147
    148148  _Mutex_Release(mtx);
     
    150150  send_event(ctx, idx, EVENT_MTX_ACQUIRE);
    151151
    152   success = _Mutex_Try_acquire(mtx);
    153   rtems_test_assert(success == 0);
     152  eno = _Mutex_Try_acquire(mtx);
     153  rtems_test_assert(eno == EBUSY);
    154154
    155155  send_event(ctx, idx, EVENT_MTX_RELEASE);
     
    160160  struct _Mutex_recursive_Control *mtx = &ctx->rec_mtx;
    161161  size_t idx = 0;
    162   int success;
    163 
    164   success = _Mutex_recursive_Try_acquire(mtx);
    165   rtems_test_assert(success == 1);
     162  int eno;
     163
     164  eno = _Mutex_recursive_Try_acquire(mtx);
     165  rtems_test_assert(eno == 0);
    166166
    167167  _Mutex_recursive_Acquire(mtx);
    168168
    169   success = _Mutex_recursive_Try_acquire(mtx);
    170   rtems_test_assert(success == 1);
     169  eno = _Mutex_recursive_Try_acquire(mtx);
     170  rtems_test_assert(eno == 0);
    171171
    172172  _Mutex_recursive_Release(mtx);
     
    176176  send_event(ctx, idx, EVENT_REC_MTX_ACQUIRE);
    177177
    178   success = _Mutex_recursive_Try_acquire(mtx);
    179   rtems_test_assert(success == 0);
     178  eno = _Mutex_recursive_Try_acquire(mtx);
     179  rtems_test_assert(eno == EBUSY);
    180180
    181181  send_event(ctx, idx, EVENT_REC_MTX_RELEASE);
Note: See TracChangeset for help on using the changeset viewer.