mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #18584 from maribu/core/mutex.c
core/mutex: fix priority inheritance on AVR
This commit is contained in:
commit
4e5931b56a
20
core/mutex.c
20
core/mutex.c
@ -157,16 +157,6 @@ void mutex_unlock(mutex_t *mutex)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MODULE_CORE_MUTEX_PRIORITY_INHERITANCE
|
||||
thread_t *owner = thread_get(mutex->owner);
|
||||
if ((owner) && (owner->priority != mutex->owner_original_priority)) {
|
||||
DEBUG("PID[%" PRIkernel_pid "] prio %u --> %u\n",
|
||||
owner->pid,
|
||||
(unsigned)owner->priority, (unsigned)owner->priority);
|
||||
sched_change_priority(owner, mutex->owner_original_priority);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mutex->queue.next == MUTEX_LOCKED) {
|
||||
mutex->queue.next = NULL;
|
||||
/* the mutex was locked and no thread was waiting for it */
|
||||
@ -188,6 +178,16 @@ void mutex_unlock(mutex_t *mutex)
|
||||
|
||||
uint16_t process_priority = process->priority;
|
||||
|
||||
#ifdef MODULE_CORE_MUTEX_PRIORITY_INHERITANCE
|
||||
thread_t *owner = thread_get(mutex->owner);
|
||||
if ((owner) && (owner->priority != mutex->owner_original_priority)) {
|
||||
DEBUG("PID[%" PRIkernel_pid "] prio %u --> %u\n",
|
||||
owner->pid,
|
||||
(unsigned)owner->priority, (unsigned)owner->priority);
|
||||
sched_change_priority(owner, mutex->owner_original_priority);
|
||||
}
|
||||
#endif
|
||||
|
||||
irq_restore(irqstate);
|
||||
sched_switch(process_priority);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user