[rtems-libbsd commit] rtems-bsd-mutex: Update due to API changes

Sebastian Huber sebh at rtems.org
Thu Jul 28 06:07:46 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Jun 28 08:32:30 2016 +0200

rtems-bsd-mutex: Update due to API changes

---

 rtemsbsd/include/machine/rtems-bsd-mutex.h     |  5 ++---
 rtemsbsd/include/machine/rtems-bsd-muteximpl.h | 21 ++++++++++-----------
 rtemsbsd/rtems/rtems-kernel-muteximpl.c        | 17 ++++++++---------
 3 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/rtemsbsd/include/machine/rtems-bsd-mutex.h b/rtemsbsd/include/machine/rtems-bsd-mutex.h
index 7bd7216..dd728cd 100644
--- a/rtemsbsd/include/machine/rtems-bsd-mutex.h
+++ b/rtemsbsd/include/machine/rtems-bsd-mutex.h
@@ -7,7 +7,7 @@
  */
 
 /*
- * Copyright (c) 2014, 2015 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2014, 2016 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -48,8 +48,7 @@ extern "C" {
 #endif /* __cplusplus */
 
 typedef struct {
-	Thread_queue_Queue queue;
-	Thread_Control *owner;
+	Thread_queue_Control queue;
 	int nest_level;
 } rtems_bsd_mutex;
 
diff --git a/rtemsbsd/include/machine/rtems-bsd-muteximpl.h b/rtemsbsd/include/machine/rtems-bsd-muteximpl.h
index 856e5f4..4175190 100644
--- a/rtemsbsd/include/machine/rtems-bsd-muteximpl.h
+++ b/rtemsbsd/include/machine/rtems-bsd-muteximpl.h
@@ -8,7 +8,7 @@
  */
 
 /*
- * Copyright (c) 2014, 2015 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2014, 2016 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -58,7 +58,6 @@ rtems_bsd_mutex_init(struct lock_object *lock, rtems_bsd_mutex *m,
     struct lock_class *class, const char *name, const char *type, int flags)
 {
 	_Thread_queue_Initialize(&m->queue);
-	m->owner = NULL;
 	m->nest_level = 0;
 
 	lock_init(lock, class, name, type, flags);
@@ -78,11 +77,11 @@ rtems_bsd_mutex_lock(struct lock_object *lock, rtems_bsd_mutex *m)
 	_Thread_queue_Context_initialize(&queue_context);
 	_Thread_queue_Acquire(&m->queue, &queue_context.Lock_context);
 
-	owner = m->owner;
+	owner = m->queue.Queue.owner;
 	executing = _Thread_Executing;
 
 	if (__predict_true(owner == NULL)) {
-		m->owner = executing;
+		m->queue.Queue.owner = executing;
 		++executing->resource_count;
 
 		_Thread_queue_Release(&m->queue, &queue_context.Lock_context);
@@ -103,11 +102,11 @@ rtems_bsd_mutex_trylock(struct lock_object *lock, rtems_bsd_mutex *m)
 	_Thread_queue_Context_initialize(&queue_context);
 	_Thread_queue_Acquire(&m->queue, &queue_context.Lock_context);
 
-	owner = m->owner;
+	owner = m->queue.Queue.owner;
 	executing = _Thread_Executing;
 
 	if (owner == NULL) {
-		m->owner = executing;
+		m->queue.Queue.owner = executing;
 		++executing->resource_count;
 		success = 1;
 	} else if (owner == executing) {
@@ -138,7 +137,7 @@ rtems_bsd_mutex_unlock(rtems_bsd_mutex *m)
 	_Thread_queue_Acquire(&m->queue, &queue_context.Lock_context);
 
 	nest_level = m->nest_level;
-	owner = m->owner;
+	owner = m->queue.Queue.owner;
 
 	BSD_ASSERT(owner == _Thread_Executing);
 
@@ -155,11 +154,11 @@ rtems_bsd_mutex_unlock(rtems_bsd_mutex *m)
 		 */
 		_Atomic_Fence( ATOMIC_ORDER_ACQ_REL );
 
-		heads = m->queue.heads;
+		heads = m->queue.Queue.heads;
 		keep_priority = _Thread_Owns_resources(owner)
 		    || !owner->priority_restore_hint;
 
-		m->owner = NULL;
+		m->queue.Queue.owner = NULL;
 
 		if (__predict_true(heads == NULL && keep_priority)) {
 			_Thread_queue_Release(&m->queue, &queue_context.Lock_context);
@@ -179,7 +178,7 @@ static inline int
 rtems_bsd_mutex_owned(rtems_bsd_mutex *m)
 {
 
-	return (m->owner == _Thread_Get_executing());
+	return (m->queue.Queue.owner == _Thread_Get_executing());
 }
 
 static inline int
@@ -192,7 +191,7 @@ rtems_bsd_mutex_recursed(rtems_bsd_mutex *m)
 static inline void
 rtems_bsd_mutex_destroy(struct lock_object *lock, rtems_bsd_mutex *m)
 {
-	BSD_ASSERT(m->queue.heads == NULL);
+	BSD_ASSERT(m->queue.Queue.heads == NULL);
 
 	if (rtems_bsd_mutex_owned(m)) {
 		m->nest_level = 0;
diff --git a/rtemsbsd/rtems/rtems-kernel-muteximpl.c b/rtemsbsd/rtems/rtems-kernel-muteximpl.c
index 4f3d647..616e0dc 100644
--- a/rtemsbsd/rtems/rtems-kernel-muteximpl.c
+++ b/rtemsbsd/rtems/rtems-kernel-muteximpl.c
@@ -7,7 +7,7 @@
  */
 
 /*
- * Copyright (c) 2014, 2015 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2014, 2016 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -43,7 +43,7 @@
 #include <rtems/score/schedulerimpl.h>
 #include <rtems/score/threadqimpl.h>
 
-#define BSD_MUTEX_TQ_OPERATIONS &_Thread_queue_Operations_priority
+#define BSD_MUTEX_TQ_OPERATIONS &_Thread_queue_Operations_priority_inherit
 
 void
 rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
@@ -56,15 +56,14 @@ rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
 
 		_Thread_queue_Release(&m->queue, &queue_context->Lock_context);
 	} else {
-		/* Priority inheritance */
-		_Thread_Raise_priority(owner, executing->current_priority);
-
 		++executing->resource_count;
 		_Thread_queue_Context_set_expected_level(queue_context, 1);
 		_Thread_queue_Context_set_no_timeout(queue_context);
-		_Thread_queue_Enqueue_critical(&m->queue,
+		_Thread_queue_Context_set_deadlock_callout(queue_context,
+		    _Thread_queue_Deadlock_fatal);
+		_Thread_queue_Enqueue_critical(&m->queue.Queue,
 		    BSD_MUTEX_TQ_OPERATIONS, executing,
-		    STATES_WAITING_FOR_MUTEX, queue_context);
+		    STATES_WAITING_FOR_SYS_LOCK_MUTEX, queue_context);
 	}
 }
 
@@ -79,8 +78,8 @@ rtems_bsd_mutex_unlock_more(rtems_bsd_mutex *m, Thread_Control *owner,
 
 		operations = BSD_MUTEX_TQ_OPERATIONS;
 		new_owner = ( *operations->first )( heads );
-		m->owner = new_owner;
-		_Thread_queue_Extract_critical(&m->queue, operations,
+		m->queue.Queue.owner = new_owner;
+		_Thread_queue_Extract_critical(&m->queue.Queue, operations,
 		    new_owner, queue_context);
 	} else {
 		_Thread_queue_Release(&m->queue, &queue_context->Lock_context);




More information about the vc mailing list