Why Windows 95 and 98 would crash after 49.7 days of uptime

栏目: IT技术 · 发布时间: 4年前

There’s a famous bug in Windows 95 and Windows 98 (now patched) that caused these systems to stop functioning after 49.7 days of uptime. I used to wonder how this happened – in addition to wondering how many Windows 95 / 98 systems could achieve such uptimes to begin with!

Finally, I did a little math and figured out what must be behind this bug. It’s actually quite cute.

First, we need to know about a function called GetTickTime which is part of the Windows API. This function returns a DWORD value representing the number of milliseconds which has elapsed since the system has come up.

What’s a DWORD? A Word on an x86 is 16 bits, so a Double Word is 32 bits. The maximum number expressed in 32 bits is 2 to the power of 32.

2^32 = 4,294,967,296

We’re expressing a number of milliseconds here. How many milliseconds are there in one day?

(milliseconds per second) * (seconds per minute) * (minutes per hour) * (hours per day) = 1000 * 60 * 60 * 24 = 86,400,000 .

Finally, we can find out how many days’ worth of milliseconds we can fit in the DWORD:

4,294,967,296 / 86,400,000 = 49.7102696

Voila! After 49.71 days, the number of milliseconds since startup exceeded the maximum value of a DWORD, and rolled to 0 (kind of like the odometer on Al Bundy’s Dodge rolling to 0 after the 999,999,999 th mile)

Depending on how you process the return value of GetTickCount(), this may or may not be a problem. Clearly some code in Windows didn’t handle this too well, and Windows hung.

References:

Microsoft Knowledge Base entry for the bug

http://support.microsoft.com/kb/q216641/

Docs for GetTickCount()

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/gettickcount.asp


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

设计原本

设计原本

Frederick P. Brooks, Jr. / InfoQ中文站、王海鹏、高博 / 机械工业出版社 / 2011-1-1 / 55.00元

无论是软件开发、工程还是建筑,有效的设计都是工作的核心。《设计原本:计算机科学巨匠Frederick P. Brooks的思考》将对设计过程进行深入分析,揭示进行有效和优雅设计的方法。 本书包含了多个行业设计者的特别领悟。Frederick P. Brooks, Jr.精确发现了所有设计项目中内在的不变因素,揭示 了进行优秀设计的过程和模式。通过与几十位优秀设计者的对话,以及他自己在几个设计......一起来看看 《设计原本》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具