![]() ![]() All three timers are driven by the system boards 14.31818 MHz crystal, divided by 12 to yield a 1.19318 MHz clock to the timers, so the timers count once every 838.1 ns. The 8253 actually contains three timers, as shown in Figure 3.1. To understand why this is so, we need to examine the way in which both the 8253 and the PCs system clock (which keeps the current time) work. Time and the PCĪ second interesting point about ZTimerOn is that it may introduce some small inaccuracy into the system clock time whenever it is called. As a result, code timed with the Zen timer should not expect any hardware interrupts to occur during the interval between any call to ZTimerOn and the corresponding call to ZTimerOff, and should not enable interrupts during that time. ( ZTimerOff later restores interrupts to the state they were in when ZTimerOn was called.) Were interrupts not disabled by ZTimerOn, keyboard, mouse, timer, and other interrupts could occur during the timing interval, and the time required to service those interrupts would incorrectly and erratically appear to be part of the execution time of the code being measured. One point of interest is that ZTimerOn disables interrupts. Two aspects of ZTimerOn are worth discussing further. (Id like to note that while Intels documentation for the 8253 seems to indicate that a timer wont reset to 0 until it finishes counting down, in actual practice, timers seem to reset to 0 as soon as theyre loaded.) ZTimerOn saves the context of the calling code, disables interrupts, sets timer 0 of the 8253 to mode 2 (divide-by-N mode), sets the initial timer count to 0, restores the context of the calling code, and returns. ZTimerOn is called at the start of a segment of code to be timed. Instead, focus on learning how to use it, and youll be on the right road. Consequently, you shouldnt worry if you dont fully grasp the inner workings of the Zen timer. In other words, the Zen timer isnt really part of the knowledge we seek rather, its one tool with which well acquire that knowledge. On the other hand, it is by no means essential that you understand exactly how the Zen timer works. Ill be using the Zen timer again and again over the course of this book, so its essential that you learn what the Zen timer can do and how to use it. Were going to spend the rest of this chapter seeing what the Zen timer can do, examining how it works, and learning how to use it. Michael Abrash's Graphics Programming Black Book Special Edition: Assume Nothing Previous ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |