I have measuered the time interval between invocations of the clock handler and its more than the value of PERIOD defined in clock.h. Whats going on?
A clock interrupt is only raised when it’s “safe” to do so. When the clock timer goes off, indicating a clock interrupt should be raised, a check is made to make sure the currently running thread is executing safe code, which is not part of an NT-supplied library. Since we have no control over what a thread might do in a library, it’s risky to interrupt it. For instance, a thread could be interrupted in the middle of a printf(), when it’s holding an NT lock. The context-switch might start another thread which also calls printf(), cannot get the lock, and blocks, causing a deadlock.