3 ms·
Asynchronous I/O figures in prominently in Windows NT but I just assumed it wasn't ever thought about in DOS (being single-tasking and single-user). I was reall
by EvanAnderson 3y ago
Asynchronous I/O figures in prominently in Windows NT but I just assumed it wasn't ever thought about in DOS (being single-tasking and single-user). I was really surprised to see[0]:
Each driver in the chain defines two entry points; the strategy routine and the interrupt routine. The 2.0 DOS does not really make use of two entry points (it simply calls strategy, then immediately calls interrupt). This dual entry point scheme is designed to facilitate future multi-tasking versions of MS-DOS. In multi-tasking environments I/O must be asynchronous, to accomplish this the strategy routine will be called to queue (internally) a request and return quickly. It is then the responsibility of the interrupt routine to perform the actual I/O at interrupt time by picking requests off the internal queue (set up by the strategy routine), and process them. When a request is complete, it is flagged as "done" by the interrupt routine. The DOS periodically scans the list of requests looking for ones flagged as done, and "wakes up" the process waiting for the completion of the request.
I didn't realize that kind of forwarding-looking perspective was going into the design of MS-DOS.
[0] https://github.com/microsoft/MS-DOS/blob/master/v2.0/source/DEVDRIV.txt https://github.com/microsoft/MS-DOS/blob/master/v2.0/source/...
- thibaut_barrere 3y agoReminds me of TSR (terminate and stay resident) programs, which felt like magic (I was happy to implement one a long time ago). TSR is an embryo of that in a way!
- febed 3y agoThis brought back memories of school when some of us cheated on programming exercises by calling up a TSR program with solutions when the teacher was out of sight. Good times.
- oso2k 3y agoI've been looking for TSR & Packet driver coding examples and resources (for a non-keyboard triggered use case). I want to implement a localhost only webserver as either a TSR or Packet Driver.
- EvanAnderson 3y agoHave you taken a look at mTCP[0]? There would be some good example code there. The TSR portion wouldn't be included in the mTCP code, but there is definitely code there for a webserver. [0]: http://www.brutman.com/mTCP/mTCP.html http://www.brutman.com/mTCP/mTCP.html
- oso2k 3y agoI have and that's the thing. Every webserver I'm aware of runs in the foreground unlike TSRs and PacketDrivers. I'm looking for a webserver that runs in the background.
- dezgeg 3y agoI wonder how many of such drivers that would in reality only work when those two are called in succession
- rep_lodsb 3y agoThey copied this driver model from UNIX/XENIX. However the way it was implemented in DOS, the interrupt routine had to always return with the "done" flag set, so a driver that was compatible with it wouldn't ever be possible to run asynchronously on a newer version. There actually was a multitasking version of MS-DOS, but it was only licensed to a few OEM's. These disk images surfaced about 10 years ago: https://www.pcjs.org/software/pcx86/sys/dos/microsoft/4.0M/ https://www.pcjs.org/software/pcx86/sys/dos/microsoft/4.0M/ https://www.os2museum.com/wp/multitasking-ms-dos-4-0-lives/ https://www.os2museum.com/wp/multitasking-ms-dos-4-0-lives/
- EvanAnderson 3y agoI knew that "Concurrent DOS" existed (non-Microsoft product) but I didn't realize that Microsoft did a multitasking DOS themselves. Very cool. Thanks for the pointer.
- xx__yy 3y agoThanks for the links. PCjs is amazing!