mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
fixup! thread_yield_higher(): assert interrupts enabled
This commit is contained in:
parent
fc76726519
commit
e5e51ef749
29
core/mutex.c
29
core/mutex.c
@ -49,7 +49,9 @@
|
|||||||
* therefore, beneficial for the majority of applications.
|
* therefore, beneficial for the majority of applications.
|
||||||
*/
|
*/
|
||||||
static inline __attribute__((always_inline))
|
static inline __attribute__((always_inline))
|
||||||
void _block(mutex_t *mutex, uinttxtptr_t pc)
|
void _block(mutex_t *mutex,
|
||||||
|
unsigned irq_state,
|
||||||
|
uinttxtptr_t pc)
|
||||||
{
|
{
|
||||||
/* pc is only used when MODULE_CORE_MUTEX_DEBUG */
|
/* pc is only used when MODULE_CORE_MUTEX_DEBUG */
|
||||||
(void)pc;
|
(void)pc;
|
||||||
@ -85,7 +87,7 @@ void _block(mutex_t *mutex, uinttxtptr_t pc)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
irq_enable();
|
irq_restore(irq_state);
|
||||||
thread_yield_higher();
|
thread_yield_higher();
|
||||||
/* We were woken up by scheduler. Waker removed us from queue. */
|
/* We were woken up by scheduler. Waker removed us from queue. */
|
||||||
#if IS_USED(MODULE_CORE_MUTEX_DEBUG)
|
#if IS_USED(MODULE_CORE_MUTEX_DEBUG)
|
||||||
@ -95,12 +97,11 @@ void _block(mutex_t *mutex, uinttxtptr_t pc)
|
|||||||
|
|
||||||
bool mutex_lock_internal(mutex_t *mutex, bool block)
|
bool mutex_lock_internal(mutex_t *mutex, bool block)
|
||||||
{
|
{
|
||||||
assert(irq_is_enabled());
|
|
||||||
uinttxtptr_t pc = 0;
|
uinttxtptr_t pc = 0;
|
||||||
#if IS_USED(MODULE_CORE_MUTEX_DEBUG)
|
#if IS_USED(MODULE_CORE_MUTEX_DEBUG)
|
||||||
pc = cpu_get_caller_pc();
|
pc = cpu_get_caller_pc();
|
||||||
#endif
|
#endif
|
||||||
irq_disable();
|
unsigned irq_state = irq_disable();
|
||||||
|
|
||||||
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_internal(block=%u).\n",
|
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_internal(block=%u).\n",
|
||||||
thread_getpid(), (unsigned)block);
|
thread_getpid(), (unsigned)block);
|
||||||
@ -121,14 +122,14 @@ bool mutex_lock_internal(mutex_t *mutex, bool block)
|
|||||||
#endif
|
#endif
|
||||||
DEBUG("PID[%" PRIkernel_pid "] mutex_lock(): early out.\n",
|
DEBUG("PID[%" PRIkernel_pid "] mutex_lock(): early out.\n",
|
||||||
thread_getpid());
|
thread_getpid());
|
||||||
irq_enable();
|
irq_restore(irq_state);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!block) {
|
if (!block) {
|
||||||
irq_enable();
|
irq_restore(irq_state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_block(mutex, pc);
|
_block(mutex, irq_state, pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -136,12 +137,11 @@ bool mutex_lock_internal(mutex_t *mutex, bool block)
|
|||||||
|
|
||||||
int mutex_lock_cancelable(mutex_cancel_t *mc)
|
int mutex_lock_cancelable(mutex_cancel_t *mc)
|
||||||
{
|
{
|
||||||
assert(irq_is_enabled());
|
|
||||||
uinttxtptr_t pc = 0;
|
uinttxtptr_t pc = 0;
|
||||||
#if IS_USED(MODULE_CORE_MUTEX_DEBUG)
|
#if IS_USED(MODULE_CORE_MUTEX_DEBUG)
|
||||||
pc = cpu_get_caller_pc();
|
pc = cpu_get_caller_pc();
|
||||||
#endif
|
#endif
|
||||||
irq_disable();
|
unsigned irq_state = irq_disable();
|
||||||
|
|
||||||
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable()\n",
|
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable()\n",
|
||||||
thread_getpid());
|
thread_getpid());
|
||||||
@ -149,7 +149,7 @@ int mutex_lock_cancelable(mutex_cancel_t *mc)
|
|||||||
if (mc->cancelled) {
|
if (mc->cancelled) {
|
||||||
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable cancelled "
|
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable cancelled "
|
||||||
"early.\n", thread_getpid());
|
"early.\n", thread_getpid());
|
||||||
irq_enable();
|
irq_restore(irq_state);
|
||||||
return -ECANCELED;
|
return -ECANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,11 +171,11 @@ int mutex_lock_cancelable(mutex_cancel_t *mc)
|
|||||||
#endif
|
#endif
|
||||||
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable() early out.\n",
|
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable() early out.\n",
|
||||||
thread_getpid());
|
thread_getpid());
|
||||||
irq_enable();
|
irq_restore(irq_state);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_block(mutex, pc);
|
_block(mutex, irq_state, pc);
|
||||||
if (mc->cancelled) {
|
if (mc->cancelled) {
|
||||||
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable() "
|
DEBUG("PID[%" PRIkernel_pid "] mutex_lock_cancelable() "
|
||||||
"cancelled.\n", thread_getpid());
|
"cancelled.\n", thread_getpid());
|
||||||
@ -237,10 +237,9 @@ void mutex_unlock(mutex_t *mutex)
|
|||||||
|
|
||||||
void mutex_unlock_and_sleep(mutex_t *mutex)
|
void mutex_unlock_and_sleep(mutex_t *mutex)
|
||||||
{
|
{
|
||||||
assert(irq_is_enabled());
|
|
||||||
DEBUG("PID[%" PRIkernel_pid "] mutex_unlock_and_sleep(): queue.next: %p\n",
|
DEBUG("PID[%" PRIkernel_pid "] mutex_unlock_and_sleep(): queue.next: %p\n",
|
||||||
thread_getpid(), (void *)mutex->queue.next);
|
thread_getpid(), (void *)mutex->queue.next);
|
||||||
irq_disable();
|
unsigned irqstate = irq_disable();
|
||||||
|
|
||||||
if (mutex->queue.next) {
|
if (mutex->queue.next) {
|
||||||
if (mutex->queue.next == MUTEX_LOCKED) {
|
if (mutex->queue.next == MUTEX_LOCKED) {
|
||||||
@ -262,7 +261,7 @@ void mutex_unlock_and_sleep(mutex_t *mutex)
|
|||||||
DEBUG("PID[%" PRIkernel_pid "] mutex_unlock_and_sleep(): going to sleep.\n",
|
DEBUG("PID[%" PRIkernel_pid "] mutex_unlock_and_sleep(): going to sleep.\n",
|
||||||
thread_getpid());
|
thread_getpid());
|
||||||
sched_set_status(thread_get_active(), STATUS_SLEEPING);
|
sched_set_status(thread_get_active(), STATUS_SLEEPING);
|
||||||
irq_enable();
|
irq_restore(irqstate);
|
||||||
thread_yield_higher();
|
thread_yield_higher();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ static void _update_head_offset(evtimer_t *evtimer)
|
|||||||
|
|
||||||
void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event)
|
void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event)
|
||||||
{
|
{
|
||||||
irq_disable();
|
unsigned state = irq_disable();
|
||||||
|
|
||||||
DEBUG("evtimer_add(): adding event with offset %" PRIu32 "\n", event->offset);
|
DEBUG("evtimer_add(): adding event with offset %" PRIu32 "\n", event->offset);
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event)
|
|||||||
if (evtimer->events == event) {
|
if (evtimer->events == event) {
|
||||||
_set_timer(evtimer);
|
_set_timer(evtimer);
|
||||||
}
|
}
|
||||||
irq_enable();
|
irq_restore(state);
|
||||||
if (sched_context_switch_request) {
|
if (sched_context_switch_request) {
|
||||||
thread_yield_higher();
|
thread_yield_higher();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user