1
0
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:
benpicco 2022-09-13 16:39:23 +02:00 committed by GitHub
commit 4e5931b56a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}