mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-16 04:46:27 +08:00
rtems-bsd-mutex: Update due to API changes
This commit is contained in:
@@ -66,22 +66,20 @@ rtems_bsd_mutex_init(struct lock_object *lock, rtems_bsd_mutex *m,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
|
void rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
|
||||||
Per_CPU_Control *cpu_self, Thread_Control *owner,
|
Thread_Control *owner, Thread_Control *executing,
|
||||||
Thread_Control *executing, ISR_lock_Context *lock_context);
|
ISR_lock_Context *lock_context);
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
rtems_bsd_mutex_lock(struct lock_object *lock, rtems_bsd_mutex *m)
|
rtems_bsd_mutex_lock(struct lock_object *lock, rtems_bsd_mutex *m)
|
||||||
{
|
{
|
||||||
ISR_lock_Context lock_context;
|
ISR_lock_Context lock_context;
|
||||||
Per_CPU_Control *cpu_self;
|
|
||||||
Thread_Control *executing;
|
Thread_Control *executing;
|
||||||
Thread_Control *owner;
|
Thread_Control *owner;
|
||||||
|
|
||||||
_ISR_lock_ISR_disable_and_acquire(&m->lock, &lock_context);
|
_ISR_lock_ISR_disable_and_acquire(&m->lock, &lock_context);
|
||||||
|
|
||||||
owner = m->owner;
|
owner = m->owner;
|
||||||
cpu_self = _Per_CPU_Get();
|
executing = _Thread_Executing;
|
||||||
executing = cpu_self->executing;
|
|
||||||
|
|
||||||
if (__predict_true(owner == NULL)) {
|
if (__predict_true(owner == NULL)) {
|
||||||
m->owner = executing;
|
m->owner = executing;
|
||||||
@@ -89,7 +87,7 @@ rtems_bsd_mutex_lock(struct lock_object *lock, rtems_bsd_mutex *m)
|
|||||||
|
|
||||||
_ISR_lock_Release_and_ISR_enable(&m->lock, &lock_context);
|
_ISR_lock_Release_and_ISR_enable(&m->lock, &lock_context);
|
||||||
} else {
|
} else {
|
||||||
rtems_bsd_mutex_lock_more(lock, m, cpu_self, owner, executing,
|
rtems_bsd_mutex_lock_more(lock, m, owner, executing,
|
||||||
&lock_context);
|
&lock_context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -66,8 +66,8 @@ rtems_bsd_mutex_priority_change(Thread_Control *thread,
|
|||||||
|
|
||||||
void
|
void
|
||||||
rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
|
rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
|
||||||
Per_CPU_Control *cpu_self, Thread_Control *owner,
|
Thread_Control *owner, Thread_Control *executing,
|
||||||
Thread_Control *executing, ISR_lock_Context *lock_context)
|
ISR_lock_Context *lock_context)
|
||||||
{
|
{
|
||||||
if (owner == executing) {
|
if (owner == executing) {
|
||||||
BSD_ASSERT(lock->lo_flags & LO_RECURSABLE);
|
BSD_ASSERT(lock->lo_flags & LO_RECURSABLE);
|
||||||
@@ -75,6 +75,7 @@ rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
|
|||||||
|
|
||||||
_ISR_lock_Release_and_ISR_enable(&m->lock, lock_context);
|
_ISR_lock_Release_and_ISR_enable(&m->lock, lock_context);
|
||||||
} else {
|
} else {
|
||||||
|
Per_CPU_Control *cpu_self;
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
_Thread_Lock_set(executing, &m->lock);
|
_Thread_Lock_set(executing, &m->lock);
|
||||||
@@ -84,7 +85,7 @@ rtems_bsd_mutex_lock_more(struct lock_object *lock, rtems_bsd_mutex *m,
|
|||||||
_RBTree_Insert(&m->rivals, &executing->RBNode,
|
_RBTree_Insert(&m->rivals, &executing->RBNode,
|
||||||
_Thread_queue_Compare_priority, false);
|
_Thread_queue_Compare_priority, false);
|
||||||
|
|
||||||
_Thread_Dispatch_disable_critical(cpu_self);
|
cpu_self = _Thread_Dispatch_disable_critical();
|
||||||
|
|
||||||
/* Priority inheritance */
|
/* Priority inheritance */
|
||||||
_Scheduler_Change_priority_if_higher(_Scheduler_Get(owner),
|
_Scheduler_Change_priority_if_higher(_Scheduler_Get(owner),
|
||||||
@@ -129,8 +130,7 @@ rtems_bsd_mutex_unlock_more(rtems_bsd_mutex *m, Thread_Control *owner,
|
|||||||
} else {
|
} else {
|
||||||
Per_CPU_Control *cpu_self;
|
Per_CPU_Control *cpu_self;
|
||||||
|
|
||||||
cpu_self = _Per_CPU_Get();
|
cpu_self = _Thread_Dispatch_disable_critical();
|
||||||
_Thread_Dispatch_disable_critical(cpu_self);
|
|
||||||
_ISR_lock_Release_and_ISR_enable(&m->lock,
|
_ISR_lock_Release_and_ISR_enable(&m->lock,
|
||||||
lock_context);
|
lock_context);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user