This commit is contained in:
Pavel 2024-11-24 00:55:54 +03:00
parent cf686ffc95
commit 86587f284d
5 changed files with 22 additions and 11 deletions

View File

@ -1785,8 +1785,6 @@ begin
thread_unlock(td);
md_test_alert;
if ((flags and TDF_ALRMPEND)<>0) then
begin
PROC_LOCK;

View File

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

View File

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

View File

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

View File

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