What is the main purpose of a context switch in an operating system?