Thursday, February 18, 2010

Multitasking with iPhone OS: What does it really mean?

Apple's new iPad is being criticized for lacking the capacity to run multiple third party applications at once, but the company has a variety of options to pursue in addressing the issue.

The iPad's iPhone OS arbitrarily limits third party apps from running in the background after the user closes the app. But this isn't because the iPhone OS "can't multitask," as the iPhone OS uses the same preemptively multitasking Mach/BSD kernel as Apple's desktop Mac OS X.

The iPhone OS is constantly running system processes that listen to the mobile network for incoming calls and texts, it runs an iPod process for playing back music all the time, it watches for background notifications being sent to idle apps, and there's a variety of other things always going on. This is the definition of multitasking.

Multitasking in the operating system

A single-tasking operating system, like the original 1984 Macintosh or the Palm OS line of PDAs, is simply incapable of running multiple concurrent applications due to design constraints.

In the mid 80s, Apple adapted the classic Mac OS to switch between apps to create a windowing environment that employed cooperative multitasking. In this model, various apps voluntarily relinquished control of the processor so that they could all appear to run at once.

The downside to this model is that an application that stopped responding could prevent other apps from sharing any processor time, effectively destroying the illusion of multitasking. Modern operating systems like Mac OS X designate a kernel task that preempts other applications so if they stop responding, the kernel can simply terminate them and other apps can continue to work.

Beyond multitasking

The iPhone OS inside the iPhone, iPod touch and the iPad is not only capable of this style of preemptive multitasking, but also employs multiprocessing, which allows different tasks to run concurrently on different processor cores.

For example, when playing back video, the iPhone can spin off the heavy lifting involved with decoding H.264 to a specialized video processor core while the main processor core continues to handle other tasks, such as listening for updates and maintaining the user interface.

Apple's secretive A4 processor in the iPad is actually a System on a Chip that incorporates multiple processor cores, each of which can handle simultaneous tasks.

Multitasking in a mobile environment

While there are certain benefits to being able to run multiple applications at once, there are also a series of reasons why Apple deliberately chose to use a security model in the iPhone OS that only allows one app to run at once.

The first is limited resources. Mobile devices have a finite amount of RAM and CPU power, so allowing multiple apps to be loaded and running all at once introduces new problems related to the mobile device's performance and battery life. It also increases the system's complexity, as users will now be forced to monitor and manage the processes running in the background.

Another problem relates to security. If apps aren't simply terminated by the user in a straightforward way as they are on the iPhone OS, users may not be aware they are still running. Background apps might provide a valuable service, but without any restrictions, they're also able to install spyware, viruses and other malicious software. That's simply not possible to do on the iPhone OS.

The multi-billion dollar malware problem on the PC desktop illustrates why unfettered software installation has both pros and cons. Even background services that seem harmless, such as Google's Latitude, can expose users to unapparent security threats if they don't have the security credentials to recognize the potential risks involved with, for example, advertising their location.

iPhone multitasking


Exceptions to Apple's sandboxed-multitasking model

Apple's mobile-optimized security model in the iPhone OS makes more sense for most users than the desktop PC model that Microsoft shifted to mobile devices in Windows Mobile in terms of usability, simplicity, and performance. However, there are still issues Apple needs to address.

The first is one that Apple acknowledged after the development of iPhone 2.0: many apps want to stay open simply to listen for external updates such as news or incoming messages. Apple's notification service rolled this functionality into a system task, so the iPhone itself listens for updates and simply badges apps or delivers a notification message for users to act on.

Outside of notifications, there are other features related to multitasking that iPad users may want to see addressed. One is local background services such as Pandora radio. Apple's forthcoming iPhone OS 4.0 is anticipated to either allow users to select specific apps to run in the background, or roll those services into the system, or to enable specific background tasks.

This could allow apps like Pandora to begin a background task that continues even when the user quits the app. With the iPad's faster processor, the ability to run a limited number of background services might be less of an issue as it currently is on the iPhone.

State and main

Another approach to delivering multitasking-related functionality without opening a Pandora's Box of security and malware problems would be to enable the system to retain the state of currently running app so that users could very quickly switch between apps.

This would enhance the iPhone OS's existing, simple model of switching between apps without introducing a drain on the system's processor, memory, and battery life, as only one primary app would still ever be running at once.

Rolling additional services into the main system apps of iPhone 4.0 would also enable third party apps to tap into multitasking and background operations without actually defeating the iPhone OS' security model and introducing lots of new complexity for users to manage.

Dashboard widgets

Another avenue Apple can explore to deliver multitasking-style functionality without inhering the same problems of Microsoft's Windows Mobile and Google's Android is hinted at by the original Macintosh: desk accessory style widgets.

While it did not actually multitask between apps, the original 1984 Macintosh did enable users to run mini apps like a calculator or scrapbook in conjunction with their primary application.

The fact that the iPad was demonstrated without the iPhone's customary Stocks, Weather, and Calculator apps may be an indication that those apps have shifted on the iPad from being full screen utilities into desk accessory widgets that can be called up within other apps, such as Apple's own iWork.

The final release of the iPad will undoubtedly introduce additional features that weren't included in the initial presentation, just as the iPhone was released with features that weren't announced at its original introduction, including the ability to watch YouTube videos. Developers are already privy to a variety of iPad features that have not yet been publicly advertised by Apple.


No comments:

Post a Comment