Context Switching and Finding Balance in Life

Some people have perfectly balanced lives and some can only live in binary mode - they are either "obsessed" with one task or "utterly disinterested" in it at any point of time. I am perfectly okay with working on something for hours and hours, but I find it extremely difficult to work on multiple things. My mind gets filled with thoughts and ideas about this single task that I can't think about anything else. It's so bad that I mostly can't respond to calls immediately - I stare at my phone for long time and then call back later or ... never. It looks like an inertia problem, but it's actually a context switch problem. Also, my brain has no concept of priorities - it just wants what it wants.

Balancing Life
Balancing Life

We reduce the car music volume while driving in an unfamiliar region and trying to find a place. People often joke and laugh at our brains - "look how it reduced volume to see better". But the poor thing is trying to concentrate, to focus on the actual task. Writers are known to lock themselves up in a basement to write, programmers pull off all night-ers  to finish off coding a module, people break up with their partners to focus better on their career - basically what they are all trying to achieve is an uninterrupted flow.

Working too much on one single task is difficult - as it needs giving up on all other things in your life. But what's more difficult is finding that elusive balance in your life. Context switching between different tasks always comes at a cost - be it money or time, but it's unavoidable in life.

TEDx Talk on "Extremes are easy, strive for balance".

Life, just like seasons, has a routine/cycle. It comes in bits and pieces and not as a lump sum. You just can't have an year of cooking, an year of working on your relationship and an year of career. You have to work on all of them every day - life can't wait. Life is not like those movie goons where each of them attack the hero in a cyclical fashion - one at a time. Juggling different things and wearing different hats is exhaustive. Sometimes dropping one thing leads to the collapse of the entire act itself(break up/getting fired affects your life drastically).

Even if you follow all those techniques of filling your day with tasks on priority basis, batching related tasks together, automating and delegating, outsourcing info from brain to paper, 80/20 Pareto's Law, Eisenhower Urgent-Important matrix etc you still need to context switch.

It's difficult to listen and empathize with your family when your mind is occupied with that code issue that you have been working on since a week, to write when there's chaos around you, to be gentle with someone when your day is going bad, to be at peace after a stressful episode, to play with your kid after a long day of being all professional.

Sometimes switching provides the much needed break or recharge. But it's difficult to detach yourself from your previous state of mind when you have too many tabs open in your mind. It just leads to more stress which affects the context switching data. Unless you have been trained like those MBA/IIM/investment banking folks to work relentlessly for longer duration under stress, this isn't good for everyone.

Context switching in computer world happens pretty much the same way as it happens in our brain.
  • Works on the task at hand.
  • Pauses and saves current task state to cache. Adds the task to end of the Queue. 
  • Loads any previously saved state of next task and starts working on it. 
  • Resumes the first task when it's time comes.
Our brain's working memory works pretty much like cache and the Queue is our To Do list. The order of tasks in this Queue can follow different mechanisms -
  • sorted as per priority(pre-emptive scheduling)
  • sorted as per upcoming deadlines
  • minimum time imposed for each task so that all the tasks get the CPU's attention - time slicing/techniques like promodoro.
  • FIFO(First In First Out) - work on tasks as they keep coming.
  • sorting as per the amount of time needed to do each task(aiming at just reducing the task stack - what looks like procrastination)
  • random.
Some tasks may have dependency on other tasks(can't start to work until spouse isn't ready), some may need to be done at exactly certain point of time(can't post/blog until Friday) and some low priority tasks can have close deadlines(must buy gift before birthday).

When we get stuck at a task, we move on to another till it gets unblocked - just like Thread Blocking. A low priority task blocking a high priority task should always become the highest priority task- priority inheritance.

Putting off tasks until just before deadline and batching related things together can actually be helpful in many cases. Idea incubation actually benefits from deliberate procrastination - where your mind gets to iterate over the same topic multiple times. For example, this post has been in my writing list since so many months - over a period of time, many related ideas accumulated together about balancing, context switch in computers, different techniques etc.

Adam Grant's TED talk on deliberate procrastination:

Asynchronous style of working is good for many tasks. Don't act immediately on interruptions. Disable all those annoying notifications. Check periodically.

Do not give too small time slices for each task - that's just giving more time to switching than to the actual task. Never start a task, if you think you can't give it the minimum amount of time slot. You just don't start the server just before leaving for home.

Just like computers, we are also limited in memory storage, working memory capacity and expensive resources(help/delegation). Our working memory is what saves the context switching data and too much information leads to loss of some information(stack overflow). You may gradually forget the things you haven't worked on in a while(discard LRU-Least Recently Used). Or instead of loss of info, it may take too much time for memory retrieval(like Google's 100th page results) as they end up in some limbo/subconscious(may be only some kind of hypnosis kinda session can retrieve them). The more unrelated these memories are(guitar and coding), the more complicated the hierarchy of storage can get(just like file systems). Even memory palace techniques may fail to retrieve such deep level of memory hierarchies.

Responsiveness and throughput are the measuring factors of a computers performance. It should have enough throughput on each task, but should be responsive to any user's input(mouse click/key stroke etc). So should we be. We need to focus enough on our current tasks but we should be responsive enough to the other aspects of life. Striking a balance between these two is the key. If you are too responsive by immediately giving attention to each and every interruption, you become too slow at your tasks. Handling too many tasks and too much info comes at the cost of enormous delays. The sum of all the context switches itself may take more time compared to the amount of time spent on actually working on the tasks. Also, too many context switches mean too much info in cache - which leads to invalidating some part of the cache always. So you just lose the progress you made and need to start over as you keep replacing parts of your working memory. Sometimes a refresh may help, but not always. You end up like the distracted kid trying to study and reads only the "Once upon a time" part infinite times.

To start fresh, a "build clean"/"project clean" is done. What this does is basically erase any temp info and allow better assimilation of new changes. This in our lives is sleep. Sleep is the clean build - clears off yesterday's worries(at least to some extent) and makes your mind fresh. That joke about getting overwhelmed by zillions of things to do and deciding to take a nap- it's a good thing. This is why allotting one day to one thing(major) works - like Elon Musk focusing on SpaceX, Tesla, etc on different days.

Don't let your entire life just end up in sustenance(samsara sagaram) with no progress. This is like DOS(Denial of Service) - where servers end up busy servicing fake requests and have no time to service the actual user requests. There's more to it.

Switch wisely. 


References :
- Algorithms to live by
- Context switching in computers.


Popular Posts from last 7 days

Random posts from the past!