I once had the same experiance
I guess if u run your progamm on NT it will be OK,your trouble on 95/98 attributes to the implmentation of 95/98 's multithread - If one thread of a process is reading/writing hard disk,the other processes or threads will not get CPU time unless the reading/writing is finished.
One solution which I took : Sleep for 100~200 ms in your thread which reads or writes hard disk
;code in initializing procedure
...
;Create mutex, if failure, abort resident
push ecx
push edx
VmmCall _CreateMutex, < 0, MUTEX_MUST_COMPLETE >
pop edx
pop ecx
or eax, eax
mov dMutex, eax
mov eax, ERROR_CREATE_MUTEX
jz lVSD_ret_CY
...
;==============================================================================
;
; Gate32_Write_Handler() - Handle writing routine for commands
;
; Entry: ebx is IOP
; Exit: al set to 0 to indicate calldown, set to 1 indication callback
; al set to 2 to indicate return without calldown or callback
;
; Destroys: eax
;
;==============================================================================
beginproc Gate32_Write_Handler
AssertIOP (ebx)
push edi
VmmCall Get_Cur_Thread_Handle ;use current thread handle as reenter flag (dInterFlag)
cmp edi, dInterFlag ;if it's reenter?
pop edi
xor eax, eax
jz lGWH_ret ;it's reenter, return to calldown
; enter mutex
push eax
push ecx
push edx
VmmCall _EnterMutex, <dMutex, 0>
pop edx
pop ecx
pop eax
; set current thread handle to dInterFlag
push edi
VmmCall Get_Cur_Thread_Handle
mov dInterFlag, edi
pop edi
Call Prv_Write_Handler ;该过程处理硬盘写操作,内部读写请求较多,耗时约10-500ms
mov dInterFlag, 0 ;clear reenter flag