From 6d85d68496639b97e8f9c1d88655633bf66986cf Mon Sep 17 00:00:00 2001 From: acevest Date: Sat, 11 May 2024 22:40:01 +0800 Subject: [PATCH] =?utf8?q?=E4=BB=A5=E6=9B=B4=E7=BB=86=E7=9A=84=E7=B2=92?= =?utf8?q?=E5=BA=A6=E5=88=A4=E6=96=AD=E6=AF=8F=E8=BD=AE=E4=B8=8B=E5=8D=8A?= =?utf8?q?=E9=83=A8=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E6=98=AF=E5=90=A6?= =?utf8?q?=E8=B6=85=E6=97=B6=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- kernel/irq.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/kernel/irq.c b/kernel/irq.c index 2b03adb..74d6f47 100644 --- a/kernel/irq.c +++ b/kernel/irq.c @@ -151,10 +151,27 @@ __attribute__((regparm(1))) void irq_handler(pt_regs_t *regs) { extern uint32_t jiffies; void irq_bh_handler() { - uint32_t end = jiffies + 2; + uint32_t end = jiffies + 1; while (true) { irq_bh_action_t *action = NULL; +#if 1 + disable_irq(); + action = irq_bh_actions; + if (action == NULL) { + enable_irq(); + break; + } + + irq_bh_actions = action->next; + if (irq_bh_actions == NULL) { + irq_bh_actions_end = NULL; + } + enable_irq(); + + action->handler(action->arg); + kfree(action); +#else disable_irq(); action = irq_bh_actions; @@ -173,7 +190,7 @@ void irq_bh_handler() { action = action->next; kfree(p); } - +#endif if (jiffies >= end) { break; } @@ -227,6 +244,9 @@ int request_irq(unsigned int irq, void (*handler)(unsigned int, pt_regs_t *, voi void add_irq_bh_handler(void (*handler)(), void *arg) { // 只能在中断处理函数中调用 assert(irq_disabled()); + assert(reenter >= 0); + + // 本函数不用考虑临界问题 irq_bh_action_t *p; p = (irq_bh_action_t *)kmalloc(sizeof(irq_bh_action_t), 0); -- 2.44.0