Microsoft interview question

How is a context switch handled by the operating system?