Sam Gentle.com

The problem with preemption

A visual comparison of cooperative vs preemptive scheduling

Much like a person, an operating system needs to multitask. It can only do one thing at a time, so when you ask it to play music while you edit a document and a webpage loads in the background, it needs to find some way to split up those tasks into small pieces and structure them so that everything happens smoothly. This is called scheduling, and it remains a tricky problem even after half a century of operating system development.

These days, most schedulers are preemptive, which is to say that the operating system decides how much time each task gets before cutting it off and moving on to the next task. However, there is another, earlier model called cooperative multitasking. In the cooperative model, the tasks themselves decide how long they should take. This is simpler and more efficient, because instead of being cut off right in the middle of something, your tasks can run uninterrupted until a convenient stopping point. The drawback is that one bad task could take too long or never hand control back, leaving the whole system laggy or stalled completely.

The way we manage our own time has a similar tradeoff. You can only work on one task at a time, so you need to find some way to schedule all the things that come in. Traditionally, this scheduling is preemptive: someone comes by your desk, calls you, messages you or whatever to ask you to do something. You stop what you're doing, respond to their task, then return to your own task. Lately, in recognition of the costs of preemption in terms of focus and efficiency, many people have been moving towards a more cooperative model, where instead of being interrupted mid-task, you take breaks at the end of a task to check for messages.

In stark opposition to this is the rise of notification systems. These have become hugely popular, originally on mobile but now on desktop too. With notifications, every app can preempt you whenever it wants your attention. Why did we decide this was a good idea? Well, I'm not convinced we did. Rather, I think tools have an incentive to interrupt us more often because they get more activity that way. You can see the extremes of this in the way that mobile apps now invent new and useless categories of notifications so that they can appear on your screen more often.

I'm beginning to think the only solution to this is to turn off notifications entirely, or at least leave your phone on a do-not-disturb setting and only check it when you're not doing something else. It'd be great if there was an option in current notification systems to support this, where it would collect activity for you, but only show it to you when you ask rather than interrupting you in real time. These would be cooperative rather than preemptive notifications.

That said, there are the same drawbacks to the cooperative model for us as there are for operating systems. Checking less frequently increases throughput, but decreases responsiveness. Depending on how long it is between tasks, you can end up missing things that actually do need to happen in real time. And, if one of your tasks ends up taking way longer than you expected, it can bring everything else to a halt.

So perhaps there is still a need for preemption, but not nearly as many as the real-time notification orthodoxy would have you believe. At the very least, it would nice to have a hybrid model with some separation between notifications, which demand immediate attention, and activity, which is just some things that have happened and you might want to know about.