diff --git a/sys/kern/kern_sig.pas b/sys/kern/kern_sig.pas index 3a4f9f36..11be3c55 100644 --- a/sys/kern/kern_sig.pas +++ b/sys/kern/kern_sig.pas @@ -1785,8 +1785,6 @@ begin thread_unlock(td); - md_test_alert; - if ((flags and TDF_ALRMPEND)<>0) then begin PROC_LOCK; diff --git a/sys/kern/sched_ule.pas b/sys/kern/sched_ule.pas index cea85c18..c5425cae 100644 --- a/sys/kern/sched_ule.pas +++ b/sys/kern/sched_ule.pas @@ -131,6 +131,9 @@ begin Result:=msleep_td(slptick); thread_lock(td); + + //reset thread wakeup queue after lock + md_reset_wakeup; end; function setrunnable(td:p_kthread):Integer; diff --git a/sys/kern/subr_sleepqueue.pas b/sys/kern/subr_sleepqueue.pas index cd52cfa0..36a0efa6 100644 --- a/sys/kern/subr_sleepqueue.pas +++ b/sys/kern/subr_sleepqueue.pas @@ -262,7 +262,8 @@ begin Assert(td^.td_sleepqueue=nil); Assert(wchan<>nil); - td^.td_slptick:=time; + //Hack: callout_reset_curcpu(@td^.td_slpcallout, timo, sleepq_timeout, td); + td^.td_slptick :=time; td^.td_slpcallout:=@sleepq_timeout; end; @@ -440,6 +441,8 @@ begin r:=mi_switch(SW_VOL or SWT_SLEEPQ); + //Hack: call sleepq_timeout on timeout + if (r=ETIMEDOUT) then if (td^.td_slpcallout=Pointer(@sleepq_timeout)) then begin sleepq_timeout(td); @@ -450,7 +453,10 @@ begin mtx_lock(td^.tdq_lock); thread_lock_set(td,@td^.tdq_lock); - Assert(TD_IS_RUNNING(td),'running but not TDS_RUNNING'); + if not TD_IS_RUNNING(td) then + begin + Assert(false,'running but not TDS_RUNNING'); + end; end; { @@ -474,6 +480,11 @@ begin if ((td^.td_flags and TDF_TIMOFAIL)<>0) then begin td^.td_flags:=td^.td_flags and (not TDF_TIMOFAIL); + end else + begin + //Hack: callout_stop(@td^.td_slpcallout) + td^.td_slptick :=0; + td^.td_slpcallout:=nil; end; end; diff --git a/sys/md/md_context.pas b/sys/md/md_context.pas index 93e48355..c55c6b8e 100644 --- a/sys/md/md_context.pas +++ b/sys/md/md_context.pas @@ -105,8 +105,6 @@ procedure _set_ucontext(dst:PCONTEXT;src:p_ucontext_t); function md_get_fpcontext(td:p_kthread;mcp:p_mcontext_t;xstate:Pointer):Integer; -procedure md_test_alert; - procedure ipi_sigreturn; function ipi_send_cpu(td:p_kthread):Integer; @@ -600,11 +598,6 @@ begin //xmm,ymm end; -procedure md_test_alert; -begin - NtTestAlert(); -end; - procedure switch_to_jit(td:p_kthread); external; procedure ipi_sigreturn; diff --git a/sys/md/md_sleep.pas b/sys/md/md_sleep.pas index 06cc2b00..0cecd960 100644 --- a/sys/md/md_sleep.pas +++ b/sys/md/md_sleep.pas @@ -12,6 +12,7 @@ uses function msleep_td(timo:Int64):Integer; function wakeup_td(td:p_kthread):Integer; +procedure md_reset_wakeup; procedure md_yield; implementation @@ -69,6 +70,11 @@ begin Result:=ntw2px(NtQueueApcThread(td^.td_handle,@_apc_null,nil,nil,0)); end; +procedure md_reset_wakeup; +begin + NtTestAlert(); +end; + procedure md_yield; begin NtYieldExecution;