fix spin-locking of INTR_TOP

This commit is contained in:
NIIBE Yutaka
2015-09-08 14:46:11 +09:00
parent f6d79e6821
commit 80408902d7
3 changed files with 12 additions and 1 deletions

View File

@@ -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.

View File

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

View File

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