summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-24 10:42:35 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-24 10:42:35 +0200
commit07ff2c1910189fa49cfdf1ed1a799d1fd47ecb3c (patch)
treea9e19f4b2325a65ab8fe0d80590b007d974309e5
parentUpdate due to header guard changes (diff)
downloadrtems-libbsd-07ff2c1910189fa49cfdf1ed1a799d1fd47ecb3c.tar.bz2
rtems-bsd-mutex: Update due to API changes
-rw-r--r--rtemsbsd/include/machine/rtems-bsd-mutex.h2
-rw-r--r--rtemsbsd/include/machine/rtems-bsd-muteximpl.h13
-rw-r--r--rtemsbsd/rtems/rtems-bsd-muteximpl.c18
3 files changed, 20 insertions, 13 deletions
diff --git a/rtemsbsd/include/machine/rtems-bsd-mutex.h b/rtemsbsd/include/machine/rtems-bsd-mutex.h
index 8c1638bb..7bd7216a 100644
--- a/rtemsbsd/include/machine/rtems-bsd-mutex.h
+++ b/rtemsbsd/include/machine/rtems-bsd-mutex.h
@@ -48,7 +48,7 @@ extern "C" {
#endif /* __cplusplus */
typedef struct {
- Thread_queue_Control queue;
+ Thread_queue_Queue queue;
Thread_Control *owner;
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 0bb23f2e..3fd5cfb1 100644
--- a/rtemsbsd/include/machine/rtems-bsd-muteximpl.h
+++ b/rtemsbsd/include/machine/rtems-bsd-muteximpl.h
@@ -122,7 +122,8 @@ rtems_bsd_mutex_trylock(struct lock_object *lock, rtems_bsd_mutex *m)
}
void rtems_bsd_mutex_unlock_more(rtems_bsd_mutex *m, Thread_Control *owner,
- int keep_priority, RBTree_Node *first, ISR_lock_Context *lock_context);
+ int keep_priority, Thread_queue_Heads *heads,
+ ISR_lock_Context *lock_context);
static inline void
rtems_bsd_mutex_unlock(rtems_bsd_mutex *m)
@@ -139,7 +140,7 @@ rtems_bsd_mutex_unlock(rtems_bsd_mutex *m)
BSD_ASSERT(owner == _Thread_Executing);
if (__predict_true(nest_level == 0)) {
- RBTree_Node *first;
+ Thread_queue_Heads *heads;
int keep_priority;
--owner->resource_count;
@@ -151,17 +152,17 @@ rtems_bsd_mutex_unlock(rtems_bsd_mutex *m)
*/
_Atomic_Fence( ATOMIC_ORDER_ACQ_REL );
- first = _RBTree_First(&m->queue.Queues.Priority, RBT_LEFT);
+ heads = m->queue.heads;
keep_priority = _Thread_Owns_resources(owner)
|| !owner->priority_restore_hint;
m->owner = NULL;
- if (__predict_true(first == NULL && keep_priority)) {
+ if (__predict_true(heads == NULL && keep_priority)) {
_Thread_queue_Release(&m->queue, &lock_context);
} else {
rtems_bsd_mutex_unlock_more(m, owner, keep_priority,
- first, &lock_context);
+ heads, &lock_context);
}
} else {
@@ -188,7 +189,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(_RBTree_Is_empty(&m->queue.Queues.Priority));
+ BSD_ASSERT(m->queue.heads == NULL);
if (rtems_bsd_mutex_owned(m)) {
m->nest_level = 0;
diff --git a/rtemsbsd/rtems/rtems-bsd-muteximpl.c b/rtemsbsd/rtems/rtems-bsd-muteximpl.c
index d7776f5a..51a53383 100644
--- a/rtemsbsd/rtems/rtems-bsd-muteximpl.c
+++ b/rtemsbsd/rtems/rtems-bsd-muteximpl.c
@@ -43,6 +43,8 @@
#include <rtems/score/schedulerimpl.h>
#include <rtems/score/threadqimpl.h>
+#define BSD_MUTEX_TQ_OPERATIONS &_Thread_queue_Operations_priority
+
void
rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
Thread_Control *owner, Thread_Control *executing,
@@ -58,7 +60,8 @@ rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
_Thread_Raise_priority(owner, executing->current_priority);
++executing->resource_count;
- _Thread_queue_Enqueue_critical(&m->queue, executing,
+ _Thread_queue_Enqueue_critical(&m->queue,
+ BSD_MUTEX_TQ_OPERATIONS, executing,
STATES_WAITING_FOR_MUTEX, WATCHDOG_NO_TIMEOUT, 0,
lock_context);
}
@@ -66,15 +69,18 @@ rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
void
rtems_bsd_mutex_unlock_more(rtems_bsd_mutex *m, Thread_Control *owner,
- int keep_priority, RBTree_Node *first, ISR_lock_Context *lock_context)
+ int keep_priority, Thread_queue_Heads *heads,
+ ISR_lock_Context *lock_context)
{
- if (first != NULL) {
+ if (heads != NULL) {
+ const Thread_queue_Operations *operations;
Thread_Control *new_owner;
- new_owner = THREAD_RBTREE_NODE_TO_THREAD(first);
+ operations = BSD_MUTEX_TQ_OPERATIONS;
+ new_owner = ( *operations->first )( heads );
m->owner = new_owner;
- _Thread_queue_Extract_critical(&m->queue, new_owner,
- lock_context);
+ _Thread_queue_Extract_critical(&m->queue, operations,
+ new_owner, lock_context);
} else {
_Thread_queue_Release(&m->queue, lock_context);
}