Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼

Embedded Systems

Phone 7 Simulates Continuity

A mobile operating system is totally different from a desktop OS when it comes to how programs start and quit. With a desktop operating system, the user typically starts and quits applications. In a mobile environment, a user is only allowed to launch an application. The system terminates them.

Borrowing Java and C# terminology, in a mobile environment, at some point the operating system scheduler "garbage collects" all the running apps and terminates them when appropriate. This pseudo garbage collector operates on launched applications that are no longer interacting with the user in the foreground. These application instances are called "background" applications, though exactly what constitutes a background application varies from device to device. Android and iOS are similar in this respect, but Windows Phone 7 handles background applications a bit differently. Let's dig it out.

All major mobile platforms allow you to have only one application at a time controlling the device. When the user starts a new application, the one the Back button or starts a new instance. At this level, all platforms are the same. With iOS and Android, application instances in the background remain live applications and can be resumed instantly when the user clicks on them or attempts to start a new instance. However, the operating system reserves the right to kill background applications in order to reclaim resources should they be needed. When the user attempts to resume a killed background application, he gets is a new instance.

In Windows Phone 7, if the user closes an application by hitting the Back button, then the application is killed and removed from memory. The application is notified of this and has a chance to save some state to the permanent storage. By fetching this state upon reloading, the application can attempt to restore the last known state and provide the user with a continuous experience.

If the user simply replaces a currently running application with another — for example, he launches another application — then the first application has ten seconds to save its state in either permanent or transient storage. Data in transient storage is managed by the operating system and maintained as long as possible depending on resource demand.

When the user resumes a previously tombstoned application, the system launches a new instance and automatically passes on any transient data. The developer is responsible for using this data to restore the previous state, thus simulating continuity. If transient data is no longer available, then the behavior is the same as if the application was explicitly closed.

A big difference between Windows Phone 7 and other mobile platforms is in the behavior of applications that aren't running. In Windows Phone 7, tombstoned applications are dead. In iOS, these background applications can get extra processing time by using a system-provided API that only allows certain tasks. In Android, background applications can trigger a special service — essentially a UI-less application — that keeps working without restrictions, which can end up being a major drain on the battery.

The bottom line is that a Windows Phone 7 user can abandon an application and then resume it exactly where he left off. This behavior is application-specific, however, and doesn't come from the operating system as it does with iOS and Android.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.