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 @@ -263,6 +263,19 @@ static DWORD CALLBACK timer_thread( void *arg ) for (;;) SleepEx( INFINITE, TRUE ); } +/*********************************************************************** + * 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 * @@ -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; }