The "Blue Screen of Death" or BSOD is a dreaded crash of Windows. I remember about 2 years ago I had an epiphany when I suddenly realized exactly what causes a BSOD of death and why Windows can't continue. I would like to share this with you in case you don't realize.
Ultimately it boils down to an unhandled exception; but it's more than that. First, what is an exception? Well as the name implies, it's an exceptional condition that has occurred outside of the expected flow of execution. Take for example the following line of pseudo-code:
x = 6 / 2;
Obviously x equals 3. But what about this:
x = 8 / 0;
What does x equal? The answer is undefined. It doesn't equal anything because you can't divide a number by 0. So how does a computer handle this? Well it can't return a value to x because that would be wrong. Even if it returned a value of 0, there would be nothing to differentiate between this and "x = 0 / 8;" This is where exceptions come in. The computer "raises" an exception telling the program that an unexpected event occurred.
As developers, we can account for exceptions when they occur. We can add special code to our program to "catch" these raised exceptions and recover from them. If however the programmer does not add code to handle exceptions, the exception raises all the way up to the OS which kills the program and reports the error to the user. If you've ever seen Dr. Watson, this is the program in Windows that handles exceptions that the programmer didn't handle.
That explains exceptions, but it still doesn't explain BSOD. Windows is divided into two parts, kernel level and user or application level. Basically everything you see and interact with is user level, and some of the under-the-covers stuff like drivers are kernel level. An unhandled exception in a kernel level program results in a BSOD. So user level is to Dr. Watson as kernel level is to BSOD.
This also explains why if you get a BSOD, 99% of the time the solution to the problem is to find the offending driver and download an updated version and hope the problem was fixed. About the only time this doesn't work is if the BSOD was ultimately caused by a hardware failure.
No comments:
Post a Comment