The invention discloses a method for implementing a high-accuracy low-CPU (
central processing unit)-occupancy
timer under
Pentium IV architecture of the Windows
operating system, relates to the technical field of
timer software development of the Windows
operating system and aims to design a
timer high in accuracy and low in CPU resources occupancy to solve the technical problem of failure in realizing high accuracy and low CPU resources occupancy during Windows multi-task time division operation. By adopting 8254 chips in a
chip set of a PC (
personal computer) under
Pentium IV architecture and writing 8254 interrupt timer driving program and APIC (
advanced programmable interrupt controller) program, an interrupt based
clock timer is realized in the Windows. By defining an interrupt
processing function, changing interrupt door structure in an interrupt descriptor table and valuating the door structure by a pointer of the self-defined interrupt
processing function, calling of user-defined interrupt
processing functions is realized, and applicable timer is realized. After test, timing accuracy can reach submillimeters, timing offset is smaller than 7 microseconds when timing is 100 microseconds, CPU occupancy is quite low, and most timing application requirements of the Windows
system are met.