summaryrefslogtreecommitdiff
path: root/src/core/ao_mutex.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-10-24 22:35:32 -0700
committerKeith Packard <keithp@keithp.com>2012-10-25 00:07:14 -0700
commite80fa6de4ccc5c4851eab9fb941f9282d2e3eb16 (patch)
tree716c76a2a0aae0ade116f1c9d959d68fedeb112a /src/core/ao_mutex.c
parentb119e19604aa557a40e848c60d98a67b5f259bbd (diff)
altos: Replace __critical usage with ao_arch_critical as needed
sdcc offers __critical as a machine-independent way to block interrupts, but as gcc doesn't, we need to use a compiler-independent construct instead. ao_arch_critical has been around since the AVR port, but some old __critical usages remained. This fixes a bunch of random hangs when communicating with MM over USB or the radio as the various stdio loops were running without interrupts blocked between the test and the sleep. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core/ao_mutex.c')
-rw-r--r--src/core/ao_mutex.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/ao_mutex.c b/src/core/ao_mutex.c
index c82a7d57..952ff462 100644
--- a/src/core/ao_mutex.c
+++ b/src/core/ao_mutex.c
@@ -22,11 +22,11 @@ ao_mutex_get(__xdata uint8_t *mutex) __reentrant
{
if (*mutex == ao_cur_task->task_id)
ao_panic(AO_PANIC_MUTEX);
- __critical {
+ ao_arch_critical(
while (*mutex)
ao_sleep(mutex);
*mutex = ao_cur_task->task_id;
- }
+ );
}
void
@@ -34,8 +34,8 @@ ao_mutex_put(__xdata uint8_t *mutex) __reentrant
{
if (*mutex != ao_cur_task->task_id)
ao_panic(AO_PANIC_MUTEX);
- __critical {
+ ao_arch_critical(
*mutex = 0;
ao_wakeup(mutex);
- }
+ );
}