From c8ccedf569da3a48574ae16ba40ba26c1095ed5c Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Sun, 1 Mar 2026 20:44:14 -0600 Subject: [PATCH] Change default FIFO trigger from 8 to 1, yield CPU when idle Default RX FIFO trigger level of 8 (FCR_TRIG_8) caused exactly 8 characters to buffer in hardware before the ISR fired. Change default to 1 (FCR_TRIG_1) for responsive single-character interrupts while keeping the 16-byte FIFO enabled as a safety buffer. COMnRxTRIGGER SYSTEM.INI key still allows override. The PM_NOYIELD polling loop never yielded the CPU timeslice, starving other Windows applications. Add Yield call when no serial data is flowing so other apps get CPU time. During bulk data flow HasData stays true and the loop runs at full speed. Co-Authored-By: Claude Opus 4.6 --- delphi/TESTMAIN.PAS | 18 +++++++++++++++--- drv/commdrv.c | 12 ++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/delphi/TESTMAIN.PAS b/delphi/TESTMAIN.PAS index 77330b3..e6114ff 100644 --- a/delphi/TESTMAIN.PAS +++ b/delphi/TESTMAIN.PAS @@ -166,8 +166,9 @@ end; procedure TMainForm.Run; var - Msg: TMsg; - S: string; + Msg: TMsg; + S: string; + HasData: Boolean; begin Show; FDone := False; @@ -188,17 +189,28 @@ begin if FDone then Break; - { Poll serial data -- read one chunk, then yield to messages } + { Poll serial data -- read one chunk per iteration } + HasData := False; if FComm.PortOpen then begin S := FComm.Input; if Length(S) > 0 then + begin FAnsi.WriteDeferred(S); + HasData := True; + end; end; { Tick blink (dirties rows if interval elapsed), then render } FAnsi.TickBlink; FAnsi.FlipToScreen; + + { Yield CPU to other apps when no serial data is flowing. } + { PM_NOYIELD keeps message draining fast; Yield here gives other } + { apps a timeslice only when idle. During bulk data flow, HasData } + { stays True and the loop runs at full speed. } + if not HasData then + Yield; end; end; diff --git a/drv/commdrv.c b/drv/commdrv.c index c935692..fca2538 100644 --- a/drv/commdrv.c +++ b/drv/commdrv.c @@ -1043,21 +1043,21 @@ static void initPortState(PortStateT *port, int16_t commId) trigKey[11] = 'E'; trigKey[12] = 'R'; trigKey[13] = '\0'; - rxTrigger = readSystemIni("386Enh", trigKey, 8); + rxTrigger = readSystemIni("386Enh", trigKey, 1); } switch (rxTrigger) { - case 1: - port->fifoTrigger = FCR_TRIG_1; - break; case 4: port->fifoTrigger = FCR_TRIG_4; break; + case 8: + port->fifoTrigger = FCR_TRIG_8; + break; case 14: port->fifoTrigger = FCR_TRIG_14; break; - case 8: + case 1: default: - port->fifoTrigger = FCR_TRIG_8; + port->fifoTrigger = FCR_TRIG_1; break; }