From 76e5c012095e8f0352c5a645f8fadfac48539e3a Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 1 Feb 2010 12:58:29 +0100 Subject: [PATCH] kernel: Only start the BIOS timer if there is an actual access to selector 0x40. --- dlls/krnl386.exe16/dosexe.h | 1 + dlls/krnl386.exe16/dosmem.c | 14 +++++++++++++- dlls/krnl386.exe16/instr.c | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dlls/krnl386.exe16/dosexe.h b/dlls/krnl386.exe16/dosexe.h index d25a411c13e..fa73207e612 100644 --- a/dlls/krnl386.exe16/dosexe.h +++ b/dlls/krnl386.exe16/dosexe.h @@ -393,6 +393,7 @@ extern DOSCONF *DOSCONF_GetConfig( void ); /* dosmem.c */ extern BIOSDATA *DOSVM_BiosData( void ); +extern void DOSVM_start_bios_timer(void); /* fpu.c */ extern void WINAPI DOSVM_Int34Handler(CONTEXT86*); diff --git a/dlls/krnl386.exe16/dosmem.c b/dlls/krnl386.exe16/dosmem.c index c73faf14b96..e9acd66a4cb 100644 --- a/dlls/krnl386.exe16/dosmem.c +++ b/dlls/krnl386.exe16/dosmem.c @@ -264,6 +264,19 @@ static DWORD CALLBACK timer_thread( void *arg ) } /*********************************************************************** + * DOSVM_start_bios_timer + * + * Start the BIOS ticks timer when the app accesses selector 0x40. + */ +void DOSVM_start_bios_timer(void) +{ + static LONG running; + + if (!InterlockedExchange( &running, 1 )) + CloseHandle( CreateThread( NULL, 0, timer_thread, DOSVM_BiosData(), 0, NULL )); +} + +/*********************************************************************** * DOSMEM_Collapse * * Helper function for internal use only. @@ -335,7 +348,6 @@ BOOL DOSMEM_InitDosMemory(void) DOSMEM_Available()); DOSVM_InitSegments(); - CloseHandle( CreateThread( NULL, 0, timer_thread, DOSVM_BiosData(), 0, NULL )); SetEvent( hRunOnce ); done = 1; diff --git a/dlls/krnl386.exe16/instr.c b/dlls/krnl386.exe16/instr.c index 6ba985cf31d..a1eb68c4a57 100644 --- a/dlls/krnl386.exe16/instr.c +++ b/dlls/krnl386.exe16/instr.c @@ -104,6 +104,7 @@ static BOOL INSTR_ReplaceSelector( CONTEXT86 *context, WORD *sel ) { if (*sel == 0x40) { + DOSVM_start_bios_timer(); *sel = DOSMEM_BiosDataSeg; return TRUE; } -- 2.11.4.GIT