Alexandre Julliard : kernel: Only start the BIOS timer if there is an actual access to selector 0x40.

Alexandre Julliard julliard at winehq.org
Mon Feb 1 08:56:02 CST 2010


Module: wine
Branch: master
Commit: 76e5c012095e8f0352c5a645f8fadfac48539e3a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=76e5c012095e8f0352c5a645f8fadfac48539e3a

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Feb  1 12:58:29 2010 +0100

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 deletions(-)

diff --git a/dlls/krnl386.exe16/dosexe.h b/dlls/krnl386.exe16/dosexe.h
index d25a411..fa73207 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 c73faf1..e9acd66 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 6ba985c..a1eb68c 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;
     }




More information about the wine-cvs mailing list