summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2015-09-08 14:46:11 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2015-09-08 14:46:11 +0900
commit80408902d728c0aa2208e5fa56b4efda557e2f59 (patch)
tree7cac0b2a05a423d3684358ade9a0cca3f8520caf
parentf6d79e68213f46679715bad546b33006fb553d79 (diff)
fix spin-locking of INTR_TOP
-rw-r--r--ChangeLog5
-rw-r--r--chopstx.c7
-rw-r--r--chopstx.h1
3 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index aef32e5..b820664 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-08 Niibe Yutaka <gniibe@fsij.org>
+
+ * chopstx.c (intr_lock): New variable.
+ * chopstx.h (chx_intr): Remove member LOCK.
+
2015-09-07 Niibe Yutaka <gniibe@fsij.org>
* example-primer2: New from Kazumoto Kojima.
diff --git a/chopstx.c b/chopstx.c
index 8224ba6..4776dbd 100644
--- a/chopstx.c
+++ b/chopstx.c
@@ -741,6 +741,7 @@ chx_set_intr_prio (uint8_t n)
}
static chopstx_intr_t *intr_top;
+static struct chx_spinlock intr_lock;
static volatile uint32_t *const ICSR = (uint32_t *const)0xE000ED04;
void
@@ -753,6 +754,7 @@ chx_handle_intr (void)
"sub %0, #16" /* Exception # - 16 = interrupt number. */
: "=r" (irq_num) : /* no input */ : "memory");
chx_disable_intr (irq_num);
+ chx_spin_lock (&intr_lock);
for (intr = intr_top; intr; intr = intr->next)
if (intr->irq_num == irq_num)
break;
@@ -767,6 +769,7 @@ chx_handle_intr (void)
chx_request_preemption ();
}
}
+ chx_spin_unlock (&intr_lock);
}
void
@@ -1285,8 +1288,10 @@ chopstx_claim_irq (chopstx_intr_t *intr, uint8_t irq_num)
chx_cpu_sched_lock ();
chx_disable_intr (irq_num);
chx_set_intr_prio (irq_num);
+ chx_spin_lock (&intr_lock);
intr->next = intr_top;
intr_top = intr;
+ chx_spin_unlock (&intr_lock);
chx_cpu_sched_unlock ();
}
@@ -1304,6 +1309,7 @@ chopstx_release_irq (chopstx_intr_t *intr0)
chx_cpu_sched_lock ();
chx_enable_intr (intr0->irq_num);
+ chx_spin_lock (&intr_lock);
intr_prev = intr_top;
for (intr = intr_top; intr; intr = intr->next)
if (intr == intr0)
@@ -1313,6 +1319,7 @@ chopstx_release_irq (chopstx_intr_t *intr0)
intr_top = intr_top->next;
else
intr_prev->next = intr->next;
+ chx_spin_unlock (&intr_lock);
chx_cpu_sched_unlock ();
}
diff --git a/chopstx.h b/chopstx.h
index cf8b233..5c9b216 100644
--- a/chopstx.h
+++ b/chopstx.h
@@ -84,7 +84,6 @@ void chopstx_cond_broadcast (chopstx_cond_t *cond);
typedef struct chx_intr {
struct chx_intr *next;
- struct chx_spinlock lock;
struct chx_thread *tp;
uint32_t ready;
uint8_t irq_num;