Do the Impossible: Multitask (Part 1 of 5)

Categories: How-to's, Product Development, Productivity

Multitasking is a necessity. Learn to be an executing machine. (This article is also on Medium)

I’ve always been a proponent of “work hard, play hard”?—?sure, ultimately you have to get things done, but no matter what effort you’re putting your time into, you should do it well and with the utmost focus. When you’re at play (partying, sports, art class, whatever),?—?don’t think about work stuff. When you’re spending time on different work tasks, give each one your undivided attention and know when and how to switch. However, it seems that there are always more demands than time will allow for, and so knowing how to manage multiple tasks well is an asset.

I can hear you shouting ‘Hold on! Look at all the articles about how multitasking doesn’t work!’ —I’d argue, that most people just don’t know how to multitask well, and rather than learn how, they become advocates against it.

One of the problems lies in confusing multitasking with multiprocessing. The former is a necessity. The latter, often a futile endeavor. A second problem is not knowing how to do each of those effectively.

I have to concede there are times at which I thought I was multitasking, but in reality I was simply doing each task sufficiently enough to just get by. Gone are the days in high school where I had convinced myself that studying in front of the TV was optimal. Fortunately, the impositions on time were not as high, and in general I found most classes pretty low demanding, thus I could watch Arsenio and study for Calculus at the same time. Conversely, I’d be lying if I argued that the times I tried to watch TV and study for English theory (which I hated!), didn’t result in a poor showing on the exam.

However, people multitask and multiprocess all the time. The art is knowing what you can and cannot multitask or multiprocess and the difference between the two. First, let’s briefly outline the difference. I’m a bit of a techie so I usually make analogies with related terms. Multitasking and multiprocessing are two distinct paradigms within a computer system. Multitasking is generally a software (OS) level function which uses various flags, routines, and methods to switch between tasks on shared hardware. Multiprocessing is generally a combination of separate hardware and software which simultaneously perform different computations at the same time. With the proliferation of multi-core chips and distinct chips for graphics or audio, multiprocessing is more feasible.

For example, a computer can process the input/output from a USB port on the core chip, while at the same time process the needs for a graphic rendering on your screen using the graphics chip. This is multiprocessing?—?different processing components, processing separate activities at the same time. What it does not do, is process two graphics needs simultaneously on the same processor. Although to the human eye, it may seem like it is doing so, in reality, that would be what is better termed as multitasking. The processor performs the needs for one task for a period of time, stores the ‘context’ of the task, and then starts processing the second task for period of time. It then saves context of the second task and pulls the context of the first task (or third or fourth task) and processes that.

This is often unnoticeable?—?and both tasks perform sufficiently fast enough when they need the same underlying hardware/processor. In most cases though, both tasks would perform faster if running independently. Referring back to my analogy of studying and watching TV at the same time, you are not actually doing both simultaneously but rather context switching rapidly between the two?—?and as I mentioned earlier, I was only doing both sufficiently enough. If I felt I was really going to be challenged by the exam, and I really wanted to nail English theory, I would not have watched TV at the same time.

This is not a case of one plus one equaling two, though. The time to execute both processes is not the sum of running both independently. The reality is that when running one task, there are times where there is ‘dead time’. Similar to the real world, if you need to boil water and chop vegetables at the same time, to optimize your time you would not do those activities sequentially. In order to optimize your time, you would normally start to heat the pot of water and then switch focus to prepare the vegetables while you are waiting for the water to boil. Similarly, when multitasking, there are times that a computer system is waiting for a particular task to complete, during which time, it can switch to another task. For example, when waiting for a user to enter some input on a screen. Simply:

Multitasking: switching between tasks to use shared resources.

Multiprocessing: processing different tasks on separate resources at the same time.

So, now we know the basic difference between multiprocessing and multitasking, the next thing is to figure out what you can multiprocess and what you need to do to multitask, and how to do both effectively.

In the real world, you only have one ‘processor’?—?your brain. And while most of us only use a fraction of ours, it is really difficult to process multiple things at the same time.

There are simple ‘truths’?—?you can’t walk and tie your shoes at the same time (I’m sure someone will send me a YouTube clip of a circus clown who can, but in general I’m going with this being an impossibility)?—?however, walking and chewing gum at the same time? Not as difficult.

Some things actually do require multiprocessing and can be done?—?musicians often play an instrument and sing at the same time, athletes dribble a ball or handle a puck all the while keeping an eye on the rest of the players and thinking through plays. They are effectively using different body parts to process different needs simultaneously.

Without getting into the depth of the biology of how a brain works, the trick is making some tasks mechanical thus not using the part of your brain which is actually ‘thinking’, and freeing it up for other needs. For example: brushing your teeth doesn’t take much thinking (I’ve made it uber mechanical with my electric toothbrush now too), and I’m often watching news about the stock market, processing the information about the day’s news at the same time.

Alternatively though, going back to the computer architecture analogy, two tasks requiring the same processing unit?—?for example, two different requests requiring the graphics chip or two different applications requiring to write to disk (I hear some people asking WTF is a disk??) will run into contention and need to figure out how to allocate the chip cycle time.

This is where the ability to switch between tasks?—?multitasking?—?comes into play. For the nerds out there, recall back to when you learned about computer architectures and remember about the two types of multitasking: ‘cooperative multitasking’?—?where a process which is using a particular resource will ‘cooperate’ and proactively give up the resource so that someone else can use it?—?it would simply give up the resource to be a ‘nice guy’ although there is nothing forcing the release of the process. Thus in theory if one process wanted to hog the CPU, it could do so?—?this is how the original Mac and early MS-DOS machines worked.

The other type of multi-tasking is ‘preemptive multitasking’?—?this was the basis of the Amiga (the best computer ever!! OK, OK, UNIX always had preemptive multitasking). The idea behind preemptive multitasking is that each task is given a specific ‘time-slice’ to do work and it will be preemptively switched at the end of that time slice. In addition, while doing that task, there are specific interrupts that can cause a switch to happen earlier.

In this paradigm, you have to figure out what is the right time slice to be using?—?the system has a cost of saving and unsaving a context of a task for every switch, thus done too often, you’ll end up ‘thrashing’, spending the entire time-slice retrieving or saving contexts, and getting nothing accomplished. This is often what is happening when it seems like your computer is freezing up.

Cooperative multitasking, I would argue, is similar to how many people work, which is to simply work on a particular task for however long (or more often, however short) they wish.

Preemptive multitasking though, is how to multitask effectively in the real world.

Multitasking well is not trivial. It requires dedicated effort to set up the right processes, routines, flags, and priorities in order to be seen as some who ‘executes’?—?the word de-jour lately.

At its core, multitasking comes down to executing 4 functions well:

  • Prioritization (Knowing what is important)
  • Time-boxing (Setting up the right time-slices)
  • Notifications, Interrupts, Flags, and Semaphores (Urgencies vs Distractions)
  • Scheduling (Execution)

While these are each unique challenges, they often happen in collaboration with each other. For example, when you receive an interrupt during a particular time-box, you need to quickly determine the priority, and schedule it. In my follow up posts, I will go into what each of the above four functions mean, and will give brief outline of the goals. I will provide starting points for you to research more and outline some of the tools and tips that I have collected over the years.

Do you have thoughts on multitasking? Please share your tips, tricks, and tools.

Update: Part 2 is up now up


Comments or Questions? Voice them here!