[rtems commit] score: Fix return status of mutex try acquire
Sebastian Huber
sebh at rtems.org
Tue Sep 1 11:44:29 UTC 2015
Module: rtems
Branch: master
Commit: 44f3ea917f5c4a1cc23107dfe1a5d44170eabc56
Changeset: http://git.rtems.org/rtems/commit/?id=44f3ea917f5c4a1cc23107dfe1a5d44170eabc56
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Aug 31 13:37:52 2015 +0200
score: Fix return status of mutex try acquire
This fixes a copy and paste error (from libbsd).
---
cpukit/score/src/mutex.c | 18 +++++++++---------
testsuites/sptests/spsyslock01/init.c | 36 +++++++++++++++++------------------
2 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c
index f7cc121..ae637dd 100644
--- a/cpukit/score/src/mutex.c
+++ b/cpukit/score/src/mutex.c
@@ -268,7 +268,7 @@ int _Mutex_Try_acquire( struct _Mutex_Control *_mutex )
ISR_lock_Context lock_context;
Thread_Control *executing;
Thread_Control *owner;
- int success;
+ int eno;
mutex = _Mutex_Get( _mutex );
executing = _Mutex_Queue_acquire( mutex, &lock_context );
@@ -278,14 +278,14 @@ int _Mutex_Try_acquire( struct _Mutex_Control *_mutex )
if ( __predict_true( owner == NULL ) ) {
mutex->owner = executing;
++executing->resource_count;
- success = 1;
+ eno = 0;
} else {
- success = 0;
+ eno = EBUSY;
}
_Mutex_Queue_release( mutex, &lock_context );
- return success;
+ return eno;
}
void _Mutex_Release( struct _Mutex_Control *_mutex )
@@ -393,7 +393,7 @@ int _Mutex_recursive_Try_acquire( struct _Mutex_recursive_Control *_mutex )
ISR_lock_Context lock_context;
Thread_Control *executing;
Thread_Control *owner;
- int success;
+ int eno;
mutex = _Mutex_recursive_Get( _mutex );
executing = _Mutex_Queue_acquire( &mutex->Mutex, &lock_context );
@@ -403,17 +403,17 @@ int _Mutex_recursive_Try_acquire( struct _Mutex_recursive_Control *_mutex )
if ( __predict_true( owner == NULL ) ) {
mutex->Mutex.owner = executing;
++executing->resource_count;
- success = 1;
+ eno = 0;
} else if ( owner == executing ) {
++mutex->nest_level;
- success = 1;
+ eno = 0;
} else {
- success = 0;
+ eno = EBUSY;
}
_Mutex_Queue_release( &mutex->Mutex, &lock_context );
- return success;
+ return eno;
}
void _Mutex_recursive_Release( struct _Mutex_recursive_Control *_mutex )
diff --git a/testsuites/sptests/spsyslock01/init.c b/testsuites/sptests/spsyslock01/init.c
index c73fca7..8e4e3b8 100644
--- a/testsuites/sptests/spsyslock01/init.c
+++ b/testsuites/sptests/spsyslock01/init.c
@@ -125,32 +125,32 @@ static void test_recursive_acquire_normal(test_context *ctx)
{
struct _Mutex_Control *mtx = &ctx->mtx;
size_t idx = 0;
- int success;
+ int eno;
- success = _Mutex_Try_acquire(mtx);
- rtems_test_assert(success == 1);
+ eno = _Mutex_Try_acquire(mtx);
+ rtems_test_assert(eno == 0);
- success = _Mutex_Try_acquire(mtx);
- rtems_test_assert(success == 0);
+ eno = _Mutex_Try_acquire(mtx);
+ rtems_test_assert(eno == EBUSY);
_Mutex_Release(mtx);
- success = _Mutex_Try_acquire(mtx);
- rtems_test_assert(success == 1);
+ eno = _Mutex_Try_acquire(mtx);
+ rtems_test_assert(eno == 0);
_Mutex_Release(mtx);
_Mutex_Acquire(mtx);
- success = _Mutex_Try_acquire(mtx);
- rtems_test_assert(success == 0);
+ eno = _Mutex_Try_acquire(mtx);
+ rtems_test_assert(eno == EBUSY);
_Mutex_Release(mtx);
send_event(ctx, idx, EVENT_MTX_ACQUIRE);
- success = _Mutex_Try_acquire(mtx);
- rtems_test_assert(success == 0);
+ eno = _Mutex_Try_acquire(mtx);
+ rtems_test_assert(eno == EBUSY);
send_event(ctx, idx, EVENT_MTX_RELEASE);
}
@@ -159,15 +159,15 @@ static void test_recursive_acquire_recursive(test_context *ctx)
{
struct _Mutex_recursive_Control *mtx = &ctx->rec_mtx;
size_t idx = 0;
- int success;
+ int eno;
- success = _Mutex_recursive_Try_acquire(mtx);
- rtems_test_assert(success == 1);
+ eno = _Mutex_recursive_Try_acquire(mtx);
+ rtems_test_assert(eno == 0);
_Mutex_recursive_Acquire(mtx);
- success = _Mutex_recursive_Try_acquire(mtx);
- rtems_test_assert(success == 1);
+ eno = _Mutex_recursive_Try_acquire(mtx);
+ rtems_test_assert(eno == 0);
_Mutex_recursive_Release(mtx);
_Mutex_recursive_Release(mtx);
@@ -175,8 +175,8 @@ static void test_recursive_acquire_recursive(test_context *ctx)
send_event(ctx, idx, EVENT_REC_MTX_ACQUIRE);
- success = _Mutex_recursive_Try_acquire(mtx);
- rtems_test_assert(success == 0);
+ eno = _Mutex_recursive_Try_acquire(mtx);
+ rtems_test_assert(eno == EBUSY);
send_event(ctx, idx, EVENT_REC_MTX_RELEASE);
}
More information about the vc
mailing list