From 7336ddff48d57a97cacd937392e67c125b0d0060 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 26 Aug 2026 18:07:47 +0800 Subject: [PATCH] =?UTF-8?q?debug(timer):=20timer=5Fhandler=20=E6=AF=8F=202?= =?UTF-8?q?50=20=E6=8B=8D=E6=89=93=E5=8D=B0=20[T]=EF=BC=8C=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=AE=9A=E6=97=B6=E5=99=A8=E4=B8=AD=E6=96=AD=E8=A7=A6?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sti 后卡死在 timer_msleep,静态分析 PIT/PIC/IDT/ISR/timer_handler/ msleep/sched_tick 的 IR 全部正确。加串口诊断确认 ISR 是否触发: 若串口无 [T] → 中断未触发(PIC/PIT/IDT 运行期问题);有 [T] 仍挂 → ticks 未推进/ISR 未返回。用后移除。 --- VKernel/Kernel/platform/pch/timer.vp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/VKernel/Kernel/platform/pch/timer.vp b/VKernel/Kernel/platform/pch/timer.vp index 9b45895..ec7cac9 100644 --- a/VKernel/Kernel/platform/pch/timer.vp +++ b/VKernel/Kernel/platform/pch/timer.vp @@ -1,6 +1,7 @@ import platform.pch.pic as pic import platform.pch.pit as pit import sched.sched as sched +import drivers.serial.uart.serial as serial import asm import t, c @@ -12,6 +13,7 @@ ticks: t.CStatic | t.CVolatile | t.CUInt64T = 0 seconds: t.CStatic | t.CVolatile | t.CUInt32T = 0 milliseconds: t.CStatic | t.CVolatile | t.CUInt32T = 0 timer_running: t.CStatic | t.CVolatile | bool = False +_dbg_last: t.CUInt64T = 0 def timer_init(): global ticks, seconds, milliseconds, timer_running @@ -24,7 +26,7 @@ def timer_init(): pit.pit_init(TIMER_FREQUENCY) def timer_handler(): - global ticks, seconds, milliseconds, timer_running + global ticks, seconds, milliseconds, timer_running, _dbg_last if not timer_running: pic.eoi(0) return @@ -35,6 +37,10 @@ def timer_handler(): seconds = seconds + 1 milliseconds = milliseconds - 1000 c.Asm("mfence", op=[t.ASM_DESCR.CLOBBER_MEMORY]) + # [DBG] 每 250 拍打印一次,验证定时器中断是否触发(排查 sti 后挂起,用后移除) + if ticks - _dbg_last >= 250: + _dbg_last = ticks + serial.puts("[T]") sched.Scheduler.sched_tick() pic.eoi(0)