What Happens When Your Computer Crashes

What happens within your computer when it locks up or crashes? And why do some operating systems seem inherently more stable than others?