This content originally appeared on Level Up Coding - Medium and was authored by Gal Ashuach
And Now for Something Completely Different
Hint: CPUs are not the only ones required to perform them
Introduction
If you read my previous post, you might remember that I am currently partially assigned to another team. My 2nd manager gave me a new assignment this week. We had a thorough discussion via Zoom (as we live on different continents), which was followed by an instance message containing a link to a ticket in our task tracking system, and the text “Oh, I forgot to say that this is not urgent or anything, so feel free to finish your team tasks first”. My instinctive reply was “That’s ok, I love to juggle”.
Soon after that, I started thinking. In any other aspect of my life, I hate to deal with more than one task at a time. When someone asks me anything while I am not in a completely idle state, I throw a very clear exception: “I am a man. I have a single thread and no support for concurrency. Please ask me again later”. But, when it comes to work, I enjoy having several open tasks, plus a few more ideas for innovation up my sleeve, just in case I have the time for it. How do I do that? And why on Earth do I prefer it?
What is a context switch?
”From a human workforce perspective, context switching is the process of stopping work in one project and picking it back up after performing a different task on a different project.” -Todd Waits, Carnegie Mellon Software Engineering Institute blog.
Just like in CPUs, we should try to minimize the overhead of switching tasks, so switches can be performed frequently and seamlessly. Just like in CPUs, we are required to do them from time to time to function properly.
Why do we even need them?
- Sometimes we are blocked: The life cycle of a task is full of waiting points. We can wait for colleagues (QA tests, code reviews, collaborative tasks), wait for computers (CI/CD), or simply wait for a given time frame to pass (AB testing). So now what? You let your manager know you are blocked and call it a day? Of course not. Work time is not yours to kill.
- Urgent need: Just as you find your feet in your super complex task, you thought was way out of your league, the phone rings. Is that your wife? The kindergarten teacher? No — that’s a pager. Congratulations, production is now on fire, and it’s your turn to extinguish it. No time to waste, drop whatever you are doing and fix it.
- Change in prioritization: Products are live creatures, and they can evolve in different directions. Sometimes, while working on a given task, a different task becomes more important to the company, and you are expected to shift your focus. On occasion, it’s just the result of bad planning — a feature was promised, and apparently someone was already supposed to work on it. Oops. We can’t turn back the hands of time, but you are expected to quickly switch and close the gap.
Tips for performing context switches
- Store your current state: just like a CPU, you need to store the state of your progress so you can load it back later. There are several different ways of storing your state, and they are dependent on the type of work you’re doing. For example, if you are writing code, make sure to commit (or stash) your work, even if only partially complete, with informative log messages. If you have some insights about the next phases of the work and you didn’t have a chance to follow through, write them down to make sure you’ll remember how to continue. No need to go back to the drawing board in a few days, weeks, or months if you already know the answer now — just make sure you write it clearly enough so it will still make sense to your future self.
- Choose the right time to switch: In most cases, you have some degree of freedom regarding when to switch. If you do, you must pick the right time to do so. Working on a complicated task? Try to break it into mini-tasks and perform the break when completing some of them. Investigating an issue? Try to complete the current phase of your process and store the rest of the information you gather for future work before switching your focus elsewhere.
- Evaluate the cost of the switch and act accordingly: In many cases, switches are short and have very low overhead: If your manager asks you to write down your weekly progress for your team sync meeting, to check some logic in the code, or implement a tiny change — most chances are you are already five minutes and two git checkouts away from completing it. However, once in a blue moon, you might need to shift into a long and demanding task. In this case, there is a higher chance you could complete your current task before switching, or at least take your time to wrap up your progress properly.
Conclusion
In our world today, context switching is power, and with great power comes great responsibility. It gives us the ability to do more on a daily level, utilize every vacant timeframe, and react fast in urgent situations. It might be hard to get used to it at first, but before you know it, you’ll be switching between several tasks in progress without even noticing. Your sense of self-worth (and the company) will appreciate your hard work.
The Importance of Context Switches was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Level Up Coding - Medium and was authored by Gal Ashuach

Gal Ashuach | Sciencx (2025-05-09T16:18:01+00:00) The Importance of Context Switches. Retrieved from https://www.scien.cx/2025/05/09/the-importance-of-context-switches/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.