[rtems-libbsd commit] rtems-bsd-mutex: Fix resource count updates

Sebastian Huber sebh at rtems.org
Tue Jun 23 06:59:45 UTC 2015


Module:    rtems-libbsd
Branch:    master
Commit:    b22ad9f4c57587e8ab4a22438652e10ad0d2345d
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=b22ad9f4c57587e8ab4a22438652e10ad0d2345d

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Jun 23 08:58:58 2015 +0200

rtems-bsd-mutex: Fix resource count updates

---

 rtemsbsd/include/machine/rtems-bsd-muteximpl.h | 2 +-
 rtemsbsd/rtems/rtems-bsd-muteximpl.c           | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/rtemsbsd/include/machine/rtems-bsd-muteximpl.h b/rtemsbsd/include/machine/rtems-bsd-muteximpl.h
index 45f501c..0bb23f2 100644
--- a/rtemsbsd/include/machine/rtems-bsd-muteximpl.h
+++ b/rtemsbsd/include/machine/rtems-bsd-muteximpl.h
@@ -79,10 +79,10 @@ rtems_bsd_mutex_lock(struct lock_object *lock, rtems_bsd_mutex *m)
 
 	owner = m->owner;
 	executing = _Thread_Executing;
-	++executing->resource_count;
 
 	if (__predict_true(owner == NULL)) {
 		m->owner = executing;
+		++executing->resource_count;
 
 		_Thread_queue_Release(&m->queue, &lock_context);
 	} else {
diff --git a/rtemsbsd/rtems/rtems-bsd-muteximpl.c b/rtemsbsd/rtems/rtems-bsd-muteximpl.c
index c68bd46..d7776f5 100644
--- a/rtemsbsd/rtems/rtems-bsd-muteximpl.c
+++ b/rtemsbsd/rtems/rtems-bsd-muteximpl.c
@@ -57,6 +57,7 @@ rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
 		/* Priority inheritance */
 		_Thread_Raise_priority(owner, executing->current_priority);
 
+		++executing->resource_count;
 		_Thread_queue_Enqueue_critical(&m->queue, executing,
 		    STATES_WAITING_FOR_MUTEX, WATCHDOG_NO_TIMEOUT, 0,
 		    lock_context);



More information about the vc mailing list