What Exactly Happened To Hal In 2001: A Space Odyssey?

Having now read the book version of 2001: A Space Odyssey, I can now decisively answer a question that always bugged me after watching the the movie version, which was: what the hell happened to Hal? Why did he lose it and try to kill all the astronauts?