How do I know which process is causing my computer to hang? My computer is a 15" Macbook Pro with Retina display, and I'm on OS X version 10.8.2. I have had this my computer for several months. 

In the past few days, the computer has been completely "hanging", where nothing moves on the screen except the mouse pointer. If I was on a Skype call, the call goes on like normal, but I can't do anything else on my computer. Gestures don't work, so I can't switch desktops. I can't use my keyboard to quit the current application. I can't click on anything. The entire screen is completely unresponsive. The only way out is to force the computer to shut down. Then it boots up normally. It's only been happening recently, and I haven't been able to identify the cause.

Could it just be a bug that Apple needs to fix? Is there a process/app that could cause this to happen? How do I determine what caused the computer to hang?

Edit: In the Console, I do see this message many times before the reboot:

1/12/13 7:03:46.000 PM kernel[0]: vtd[0] fault: device 1:0:0 reason 0x5 W:0x1130e000


I have no idea what this means, but I thought it might be related because it does happen immediately before the bootup entry.

Edit 2: On other freezes, I see this message before a boot:

1/12/13 9:06:51.000 PM kernel[0]: NVDA(OpenGL): Channel exception! exception type = 0xd = GR: SW Notify Error


Edit 3: The problem was a faulty graphics card. I sent my computer in to Apple a while ago and they replaced the logic board, and when I got it back everything was hunky dory.
If you can't launch or switch programs (I find Spotlight is a good way to do this if everything else is hanging, just hit ⌘Space, but it may not work in your case), you could enable SSH access ahead of time, and then use another device to log in and check what's hogging your CPU.

Open Sharing Preferences and enable Remote Login. Then you can connect via SSH from another Mac, PC or iOS device (you'll need PuTTY on Windows, and one of various SSH clients available on iOS). Once you're logged in, type top -o cpu to get an updating display of processes ranked by CPU usage. That should give you a hint as to what's causing the problems.