Why Everything Stops When Everyone Waits: The Mathematical Theory of Deadlocks, Resource Allocation Graphs, Dijkstra's Banker's Algorithm, and Livelock