Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rochester!cornell!uw-beaver!tikal!amc!ipmoea!ericr From: ericr@ipmoea.UUCP (Eric Roskos) Newsgroups: comp.os.minix Subject: Interesting problem with timer (doc'n and impl'n) Message-ID: <9@ipmoea.UUCP> Date: Tue, 28-Jul-87 20:13:17 EDT Article-I.D.: ipmoea.9 Posted: Tue Jul 28 20:13:17 1987 Date-Received: Sat, 1-Aug-87 08:09:18 EDT Organization: Redmond, WA Lines: 76 Summary: Reboot DOS & timer runs too fast; comment in textbook wrong I just found an interesting problem... if this is already known or is fixed in version 1.2, I apologise, and you can disregard the rest of this message. For a good while, I've noticed that after working with Minix and then rebooting DOS, the date and time on my machine would be wrong. I first noticed it because makefiles would not work due to file dates being wrong, and I thought that either there was something wrong with my multifunction-card-clone or its software, or that Minix was somehow addressing its clock and causing it problems. Usually I'd find the date was sometime several days into the future, and the time seemed to be random. However, now I have begun to suspect that the problem may be simpler, though maybe limited to some clones like mine with non-IBM BIOSes. If you look on page 499 of the textbook, there's a comment "Initialize channel 2 of the 8253A timer to e.g. 60 Hz." It turns out (at least in the textbook version) that it does use 60 Hz, but the "channel 2" part seems wrong; if you look at the code, it is actually initializing channel 0, I think. So, I looked at my IBM Technical Reference, and up in the text description of the System Board, it says, "The three timer/counters are used by the system as follows: Channel 0 is used to time and request refresh cycles from the DMA channel, Channel 2 is used to support tone generation of the audio speaker, and Channel 1 is used by the system as a general-purpose timer providing a constant time base for implementing a time-of-day clock." (This is on page 2-4, the second paragraph.) At first I thought this meant that Minix was using the refresh timer as a TOD clock, which didn't sound so good, but then I looked back in the diagrams of the system board, and you can see back on page D-9 ("Logic 10 of 12") that actually channel 0 is connected to IRQ0, channel 1 is connected to the refresh logic, and channel 2 goes out to the speaker to produce the beep sounds. So, channel 0 is the TOD clock channel. So, it looks like the comment in the textbook is wrong, and also this Technical Reference is wrong, but the actual code is right (this IBM Manual is one I bought back when the PC first came out, so it may be that new ones are corrected; this one is dated July 1982). But, anyway, continuing this investigation, if you now go to page 469 of the textbook, you see that what the reboot code does is to reset the PIC, write back the original interrupt vectors, and do an int 19H. Now, next we go to the BIOS listing (page A-20 in my book, line 1355) and look at int 19H, and see that all int 19H does is reenable interrupts, set the DS to the BIOS's data area, read the equipment flags to see if we're supposed to boot or just go to cassette BASIC, and then assuming we are supposed to boot, it just reads the boot sector from the disk and jumps to it. (On newer machines it probably skips the cassette part.) So, at least in the BIOS I have a listing for (which again is an old BIOS), the timer doesn't get set. But, the PC's timer interrupt frequency is approx. 18.2 Hz (look back at TIMER_INT in the BIOS, near int 1A), whereas this leaves it set at 60 Hz! If I'm not mistaken, this means the clock is left running too fast if you boot DOS by typing ctrl/alt/del while MINIX is running. In fact, that does seem to be the case on my machine (a clone with the MCT BIOS), because the reason I began to suspect this might be the problem was that a program I have that reads the TOD clock to use it in a timing loop was running way too fast in the timing loop after I'd been working with Minix and then rebooted. Actually, on my machine, rebooting also has other bad side effects; the display doesn't get properly reinitialized until I reboot again after DOS has finished loading; but this timing loop had worked for nearly 2 years with no problems. I think that maybe a different reboot method would work better on a wider variety of BIOSes...? E.g., maybe zero out low memory up to the start of MINIX, then jump to FFFF0H. (Zeroing low memory because some BIOSes may keep a flag down there deciding whether to do a "warm" or "cold" reboot.) Does this seem like a more compatible approach for non-IBM compatibles? On the other hand, it may be that I am just missing some detail, and the problems I've observed are due to some problem with my multifunction card... but the above seems likely to me.