[comp.sys.ibm.pc] Disk access in a background process

aviv@techunix.BITNET (Aviv Siegel) (02/25/90)

Hello Netlanders !

        I have 2 questions concerning background processing in DOS :
        I had implemented a bg process which accesses the disk. It uses INT 1CH
(user TimerTick), INT 28H (Idle Loop) and the InDos flag to make sure entering
DOS is allowed. Before doing anything I save the current PSP and set my own.
As you can see - it was built according the well known (and undocumented :-)
rules for building an active bg TSR.
        In the last few weeks, I encountered a few problems, which can be
caused by something I'd missed in the implementation :
        1. When a program uses INT 21H for input (lke functions A,6,7 etc.),
DOS calls INT 28H while idle and reentering DOS is allowed. BUT, when a program
uses INT 16H function 0, and the InDos flag is set - no reentrance is allowed,
that means that INT 28H is not called, and checking the InDos flag in TimerTick
shows that bg process cannot be done. Thus, suspending the bg task.
        How can I overcome this ? Should I take INT 16H and implement an 'idle
loop' myself ?
        2. I use handles to make the disk accesses. I saw a strange problem
with FCB usage after the disk access had been done. The first FCB access which
consists of the sequence : Parse File Name (INT 21H/29H), Open File (21H/0FH),
Read (21H/27H), Close (21H/10H) does not work properly. It DOES NOT fail, but
returns 'garbage' - red something else instead the block meant to be read from
the disk. The next disk accesses using FCBs or handles work correctly.
This happens ONLY after bg disk access was done, and not consistently - 'only'
most of the times.
        I cannot switch to handles all the programs I use (don't have the
sources), but found a way to bypass the problem - open a dummy file using FCB,
read, close. Ad I stated, the next FCB operations (of another program) will be
successfull. Is there an explanation to this phenomena ? Solution ?

        Please answer to me directly, I will sum the answers to the net.
        Many thanks to any idea,
                                                Aviv
                                        aviv@techunix.technion.ac.il