![]() The OS programs a timer chip that then triggers an interrupt that wakes up the CPU and the OS can then schedule your thread. Ideally the CPU goes to sleep when Sleep(1) is called, in order to save power, so how does the operating system (OS) wake your thread if the CPU is sleeping? The answer is hardware interrupts. It’s worth pausing for a moment to think about how this is implemented. And so we have the Windows Sleep function – pass it the desired length of your nap in milliseconds and it wakes you up later, like this: This actually shouldn’t be done very often – threads should normally be waiting on events rather than timers – but it is sometimes necessary. It is desirable for a program to be able to go to sleep and then wake up a little while later. Timer interrupts and their raison d’êtreįirst, a bit of operating-system design context. If any of my conclusions are wrong then please let me know and I will update this. Update, 2021: this change is acknowledged now in the timeBeginPeriod documentation. Fair warning – all I have are the results of experiments I have run, so I can only speculate about the quirks and goals of this change. ![]() I think the new behavior is an improvement, but it’s weird, and it deserves to be documented. There is still an effect, and thread delays from Sleep and other functions may be less consistent than they used to be (see section below), but in general processes are no longer affected by other processes calling timeBeginPeriod. The short version is that calls to timeBeginPeriod from one process now affect other processes less than they used to. So far I have found three programs that hit problems because of this silent change. This isn’t the first time this has happened, but this change seems bigger than last time. The behavior of the Windows scheduler changed significantly in Wind(aka, the April 2020 version of Windows), in a way that will break a few applications, and there appears to have been no announcement, and the documentation has not been updated.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |