summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-08-11 09:01:42 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-08-11 12:37:16 +0200
commit691ed15cba6525fd5777aeb16a0de458568a85a5 (patch)
treeeaddcc8b244ce41a913317dac8305d626df4946b
parente1000phy: Provide local support for Marvell's 88E1512 PHY. (diff)
downloadrtems-libbsd-691ed15cba6525fd5777aeb16a0de458568a85a5.tar.bz2
rtems-bsd-mutex: Use _Thread_queue_Surrender()
-rw-r--r--rtemsbsd/include/machine/rtems-bsd-muteximpl.h13
-rw-r--r--rtemsbsd/rtems/rtems-kernel-muteximpl.c33
2 files changed, 8 insertions, 38 deletions
diff --git a/rtemsbsd/include/machine/rtems-bsd-muteximpl.h b/rtemsbsd/include/machine/rtems-bsd-muteximpl.h
index 4175190a..4a871be0 100644
--- a/rtemsbsd/include/machine/rtems-bsd-muteximpl.h
+++ b/rtemsbsd/include/machine/rtems-bsd-muteximpl.h
@@ -48,11 +48,15 @@
#include <rtems/bsd/sys/lock.h>
#include <rtems/score/threadimpl.h>
+#include <rtems/score/threadqimpl.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
+#define RTEMS_BSD_MUTEX_TQ_OPERATIONS \
+ &_Thread_queue_Operations_priority_inherit
+
static inline void
rtems_bsd_mutex_init(struct lock_object *lock, rtems_bsd_mutex *m,
struct lock_class *class, const char *name, const char *type, int flags)
@@ -122,10 +126,6 @@ rtems_bsd_mutex_trylock(struct lock_object *lock, rtems_bsd_mutex *m)
return (success);
}
-void rtems_bsd_mutex_unlock_more(rtems_bsd_mutex *m, Thread_Control *owner,
- int keep_priority, Thread_queue_Heads *heads,
- Thread_queue_Context *queue_context);
-
static inline void
rtems_bsd_mutex_unlock(rtems_bsd_mutex *m)
{
@@ -163,8 +163,9 @@ rtems_bsd_mutex_unlock(rtems_bsd_mutex *m)
if (__predict_true(heads == NULL && keep_priority)) {
_Thread_queue_Release(&m->queue, &queue_context.Lock_context);
} else {
- rtems_bsd_mutex_unlock_more(m, owner, keep_priority,
- heads, &queue_context);
+ _Thread_queue_Surrender(&m->queue.Queue,
+ RTEMS_BSD_MUTEX_TQ_OPERATIONS, heads, owner,
+ keep_priority, &queue_context);
}
} else {
diff --git a/rtemsbsd/rtems/rtems-kernel-muteximpl.c b/rtemsbsd/rtems/rtems-kernel-muteximpl.c
index 616e0dc3..3ce68a61 100644
--- a/rtemsbsd/rtems/rtems-kernel-muteximpl.c
+++ b/rtemsbsd/rtems/rtems-kernel-muteximpl.c
@@ -41,9 +41,6 @@
#include <machine/rtems-bsd-muteximpl.h>
#include <rtems/score/schedulerimpl.h>
-#include <rtems/score/threadqimpl.h>
-
-#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,40 +53,12 @@ rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
_Thread_queue_Release(&m->queue, &queue_context->Lock_context);
} else {
- ++executing->resource_count;
_Thread_queue_Context_set_expected_level(queue_context, 1);
_Thread_queue_Context_set_no_timeout(queue_context);
_Thread_queue_Context_set_deadlock_callout(queue_context,
_Thread_queue_Deadlock_fatal);
_Thread_queue_Enqueue_critical(&m->queue.Queue,
- BSD_MUTEX_TQ_OPERATIONS, executing,
+ RTEMS_BSD_MUTEX_TQ_OPERATIONS, executing,
STATES_WAITING_FOR_SYS_LOCK_MUTEX, queue_context);
}
}
-
-void
-rtems_bsd_mutex_unlock_more(rtems_bsd_mutex *m, Thread_Control *owner,
- int keep_priority, Thread_queue_Heads *heads,
- Thread_queue_Context *queue_context)
-{
- if (heads != NULL) {
- const Thread_queue_Operations *operations;
- Thread_Control *new_owner;
-
- operations = BSD_MUTEX_TQ_OPERATIONS;
- new_owner = ( *operations->first )( heads );
- 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);
- }
-
- if (!keep_priority) {
- Per_CPU_Control *cpu_self;
-
- cpu_self = _Thread_Dispatch_disable();
- _Thread_Restore_priority(owner);
- _Thread_Dispatch_enable(cpu_self);
- }
-}