Giz Explains: How Multitasking Works on a Phonematt buchanan4/29/10 3:20pmFiled to: Giz ExplainsiPhoneiPhone 4.0iphone os 4AndroidWindows phoneWindows phone 7AppleMicrosoftGoogleMultitaskingPalmWebOSPalm preprepixiTopFeature2891EditPromoteShare to KinjaToggle Conversation toolsGo to permalinkMultitasking! On phones! Everybody does it now. But each smartphone platform does it differently. Here are the various tricky ways that the major platforms try to juggle multiple apps.The ConstraintsA smartphone is a computer that fits in your pocket, but it has some constraints that a desktop doesn't, which make multitasking far trickier (hence the reason we're even explaining it). Namely, these four resources are constricted, and they're what mostly shape the way multitasking works on phones:Advertisement• Screen real-estate: There's only so much you can do with a 3-to-4 inch screen at one time • Battery life: You want your phone to actually last all day, or come close to it, right? • CPU: It's slower than anything in a laptop, because of size and battery life • Memory: There's not that much of it, also partly because of battery lifeThis fourth item, a lack of memory, means you can do far fewer things at once; there's also no disk swap in any of the major OSes, so you can't use the phone's actual storage as virtual memory, either. Lack of plentiful RAM is perhaps the most pernicious constraint after battery life, actually.AdvertisementFrom a user perspective, multitasking doesn't work so differently if you move from Windows to Linux to Mac on a desktop. But on a phone, everybody has their own ideas about how to make it work, ranging from leaving things nearly wide open for third-party apps to run willy-nilly (old-school Windows Mobile and BlackBerry) to making things pretty damn restrictive (iPhone pre-4.0 and Windows Phone 7). Even the common smartphone elements—notifications and fast app switching—can differ wildly from platform to platform. So here's the gist of how multitasking works on each major smartphone.AndroidThe Android model is perhaps the most interesting, a hybrid system that's fairly open about allowing stuff running in the background, but at the same time aims to be completely invisible to you, the end user, so that you don't have to actively manage whether an app is open or closed. It's a little complicated so we talked to an Android engineer about what's going on inside.What happens when I switch to another app? The app you switched from doesn't stop—the process stays open. At least, as long as it can. When Android detects it's running low on memory, then it kills processes to free up resources. It asks apps to save their state when you switch, so that any can be killed at any point, then reopen like it was never killed when you return to it.SponsoredWhat can apps do in the background? Android has two basic facilities for third-party multitasking—broadcast receivers and services. With a broadcast receiver, an app that goes into the background is basically asking to be told about an event, like if you move 500 meters, or your battery level hits a certain percentage. (That's how Google's apps that use push, like Gmail work—instead of pinging the server for mail constantly, it waits to receive a notification that mail has arrived.) That way the app can go away, and not use resources, but restart when something happens that it needs to act on.Services are what you'd consider more traditional background processes, with apps running to play music, or do turn-by-turn navigation—they're essentially a request from the app to say it needs to run for X amount of time.AdvertisementWhat can't apps do in the background? Remember Android's garbage battery life when it first came out? That's because there really were no restrictions on what kind of resources an app could consume in the background. Since Android 1.5, apps running in the background are capped at using 5-10 percent of the CPU altogether—which is the only major restriction placed on apps in the background. The other is that it's not easy for app to push itself to the foreground—they're supposed to the window shade notifications system.iPhone 4.0iPhone has always been a multitasking OS, but only for first-party apps. That changes with iPhone 4.0, which delivers multitasking and background processes for third-party apps, but in a characteristically tight-gripped way. Like Android, the idea is that users won't actually manage applications themselves, but that the system will take care of it for them. Unfortunately, a lot of the technical details are still wrapped up by non-disclosure agreements, but we have a basic idea of how stuff works.What happens when I switch to another app? Of the seven new multitasking services, two can come into play when you switch to another app: With fast-app switching, an app is frozen instead of killed, allowing users to immediately pick up where they left off, without having to reload the app. Since the user isn't actively managing whether applications completely quit or not, the system presumably kills apps when it has too many hanging around. (This is a lot like Android, in some respects.) The other is task finishing, where, if you leave an app when it's mid-task, the app can tell the OS it needs to keep running in the background to finish whatever it was doing.AdvertisementWhat can apps do in the background? Besides finishing a task, a third-party app is able to perform a limited set of functions in the background via Apple's new multitasking services. The difference between iPhone and Android is that with iPhone, the app isn't full-blown running, but just operating via these services. For users, that mainly comes down to VoIP (making and receiving calls via Skype or whatever), background audio (being able to listen to Pandora, Rhapsody and Slacker in the background), and background location, which comes in two flavors, cell tower location checking, to save battery life, and full GPS tracking, for navigation apps.What can't apps do in the background? Basically anything not set forth in the seven services. So if it's not VoIP, or background audio or location, it probably ain't running in the background. (It can stay frozen in memory for a speedy return, though. In situations where you don't need it to do anything while you're away, this is just as good.)WebOSPalm—newly acquired by HP mainly for its WebOS smart platform—has perhaps the most elegantly transparent approach to task-based multitasking—users do in fact manage apps, but it's so transparent, the open-apps-as-floating-cards metaphor so straightforward, it simply works. But there's actually a few different things going on with Palm's approach, which is slightly more complex than you might realize. So I talked to Palm's CTO Mitch Allen about it.