On a contemporary mobile device, if an application is running and is subsequently replaced in the foreground by another application or experience, the first application is deactivated and the application's process is terminated by the operating system. An application may be deactivated if the user presses the Start button or if the device timeout causes the lock screen to be engaged, for example.
In one system, the user may return to the application to continue an application task/experience from where the user left it. However, when returning to an application that was terminated by the operating system, the user needs to wait for the device application framework to initialize, and for the application itself to load saved state and to resume the previous experience. Resuming in this way can seem relatively slow and thus provide a somewhat undesirable user experience.
This Summary is provided to introduce a selection of representative concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used in any way that would limit the scope of the claimed subject matter.
Briefly, various aspects of the subject matter described herein are directed towards a technology by which an application is moved from a running (e.g., foreground) state into a dormant state in which the application process is retained in memory. Further, state data and execution context information are maintained in association with the application, which allows the application to be activated to the running state, e.g., in a rapid, efficient manner. In one aspect, moving the application from the running state into the dormant state includes pausing for a time duration to allow the application to prepare for the dormant state, e.g., persist data from memory, close any open files, and so forth.
In one aspect, moving the foreground application from a running state into the dormant state includes detaching at least one resource from the application, pausing at least one update notification provided by a resource to the application, canceling at least one cancellable request, pausing at least one non-cancellable request, stopping at least one thread, and/or freeing at least one application resource (e.g., memory allocated to the application).
To activate the application back from the dormant state to a foreground application in the running state, the state data and the execution context information is accessed, and at least one resource is attached to the application. Also described is resuming at least one update notification provided by a resource to the application, running a failure path for at least one cancellable request, resuming at least one non-cancellable request, firing at least one notification, recreating an resuming at least one thread, and/or recreating at least one application resource.
In one aspect, a resource monitor is configured to evaluate whether the application, when in the dormant state, is using at least one resource (e.g., CPU) beyond an allowed threshold. If so, the shell is configured to move the application from the dormant state into another state in which the process of the application is not retained in memory.
Other advantages may become apparent from the following detailed description when taken in conjunction with the drawings.
The present invention is illustrated by way of example and not limited in the accompanying figures in which like reference numerals indicate similar elements and in which:
Various aspects of the technology described herein are generally directed towards a technology in which a mobile device or the like maintains an application in a dormant state, generally corresponding to an application that cannot execute any code when in the background. To this end, the shell component/framework that comprises the (e.g., Windows® phone) application platform retains the application process in memory, and maintains state and execution context for the application, but does not allow the process to run. For example, the shell may suspend thread activity within background applications. The dormant background application regains the ability to execute code when the user brings the application to foreground.
In one implementation, the operating system does not terminate the application's process when deactivating an application. Instead, applications may go in the background and remain resident in memory. This eliminates the need to reinitialize the application and reload state, which implicitly means faster application resume time.
It should be understood that any of the examples herein are non-limiting. For one, example implementations and dormant applications are described in the context of a Windows® mobile device operating environment, however this is only for purposes of explanation, and other operating environments may benefit from the concept of a dormant application state as described herein. As such, the present invention is not limited to any particular embodiments, aspects, concepts, structures, functionalities or examples described herein. Rather, any of the embodiments, aspects, concepts, structures, functionalities or examples described herein are non-limiting, and the present invention may be used various ways that provide benefits and advantages in computing and application/task switching in general.
As exemplified in
The technology described herein is directed towards maintaining one or more applications as dormant applications 1141-114n, in which a dormant application (e.g., its process) is retained as resident in memory, in conjunction with maintaining the application's associated state and execution context. This allows a dormant application to be more rapidly activated (relative to tombstoned applications) to the foreground running state.
When deactivated, the shell/framework notifies the application and pauses for a duration (e.g., for up to ten seconds) to give the application time to prepare for becoming a dormant application. For example, the application is given time to persist memory, close any open files, and so forth.
Pausing is represented in
The shell 102 detects when an application is deactivated, and moves it into the dormant state 236. When detected, the shell 102 performs certain operations to ensure that the dormant application is not able to interfere with the new foreground application. For example, the shell 102 cancels any cancellable requests, may block API utilization, releases exclusive hardware resources attached to the deactivated application, and suspends threads created by the application or on behalf of the application. The shell suspends the application's thread activity and prevents the background application from consuming CPU cycles. By doing so, dormant background applications act as if the process was terminated by the operating system and do not continue using the device's battery or slow down the device foreground activity.
Note that for performance/perceived performance, some of these operations may be in parallel with preparing the new foreground application. For example, the shell may give the new application the display resource during the pause time so that the user does not have to wait the full ten seconds to perceive the change to the new foreground application. The foreground application may not be given the camera resource right away, e.g., in case the user inadvertently pressed the Start button, for example, and wants to return to the application that was running.
The shell detaches resources from deactivated applications. Examples of such resources include the vibration controller, sound and media player, photo/video camera, location services, sensors, networking and so forth. By doing so, in the dormant state 236, dormant background applications act as if the process was terminated by the operating system and does not continue using device resources or prevent the application in the foreground from using these resources.
The shell may release memory resources from dormant background applications to minimize the memory footprint in the operating system. The smaller the application memory footprint, the greater the number of dormant background applications that are able to reside in memory, and thus be quickly resumed.
The shell 102, e.g., via a resource monitor component 120 (
If necessary, such as when the operating system reaches out-of-memory conditions, the shell may terminate the processes of dormant background applications, e.g., by tombstoning or fully terminating by not maintaining state/a marker. This frees up memory resources (and any other shared resources) for the application in the foreground.
To summarize, when paused, the system shell operates to detach exclusive use resources from underneath the application, and detach shared use resources from underneath the application. The shell pauses update notifications provided by a resource to the application. For cancellable requests that are pending, the shell cancels them; any non-cancellable requests are paused or given a completion notification. In process (in-proc) native threads created on behalf of the application are stopped, and if possible, any out of process (out-of-proc) native threads created on behalf of the application are stopped. Any application resources that can be easily and quickly recreated are freed.
Turning to activating/resuming the application from the dormant state, upon application activation, the framework resumes the application threads and runs the normal failure paths for cancelled requests, and attaches resources on behalf of the application. More particularly, when resuming, the system shell operates to reattach exclusive use resources and restore their state. If possible, shared use resources are reattached and their state restored. Update notifications provided by a resource to the application are resumed. For cancellable requests that were cancelled, the normal failure path in the application is run. Any non-cancellable requests are resumed, and any pending completion notifications are fired. The shell recreates/resumes any in-proc native threads created on behalf of the application, and any out-of-proc native threads created on behalf of the application as needed. Freed resources are also recreated as needed.
In
With reference to
Components of the mobile device 500 may include, but are not limited to, a processing unit 505, system memory 510, and a bus 515 that couples various system components including the system memory 510 to the processing unit 505. The bus 515 may include any of several types of bus structures including a memory bus, memory controller, a peripheral bus, and a local bus using any of a variety of bus architectures, and the like. The bus 515 allows data to be transmitted between various components of the mobile device 500.
The mobile device 500 may include a variety of computer-readable media. Computer-readable media can be any available media that can be accessed by the mobile device 500 and includes both volatile and nonvolatile media, and removable and non-removable media. By way of example, and not limitation, computer-readable media may comprise computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by the mobile device 500.
Communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. The term “modulated data signal” means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, RF, Bluetooth®, Wireless USB, infrared, WiFi, WiMAX, and other wireless media. Combinations of any of the above should also be included within the scope of computer-readable media.
The system memory 510 includes computer storage media in the form of volatile and/or nonvolatile memory and may include read only memory (ROM) and random access memory (RAM). On a mobile device such as a cell phone, operating system code 520 is sometimes included in ROM although, in other embodiments, this is not required. Similarly, application programs 525 are often placed in RAM although again, in other embodiments, application programs may be placed in ROM or in other computer-readable memory. The heap 530 provides memory for state associated with the operating system 520 and the application programs 525. For example, the operating system 520 and application programs 525 may store variables and data structures in the heap 530 during their operations.
The mobile device 500 may also include other removable/non-removable, volatile/nonvolatile memory. By way of example,
In some embodiments, the hard disk drive 536 may be connected in such a way as to be more permanently attached to the mobile device 500. For example, the hard disk drive 536 may be connected to an interface such as parallel advanced technology attachment (PATA), serial advanced technology attachment (SATA) or otherwise, which may be connected to the bus 515. In such embodiments, removing the hard drive may involve removing a cover of the mobile device 500 and removing screws or other fasteners that connect the hard drive 536 to support structures within the mobile device 500.
The removable memory devices 535-537 and their associated computer storage media, discussed above and illustrated in
A user may enter commands and information into the mobile device 500 through input devices such as a key pad 541 and the microphone 542. In some embodiments, the display 543 may be touch-sensitive screen and may allow a user to enter commands and information thereon. The key pad 541 and display 543 may be connected to the processing unit 505 through a user input interface 550 that is coupled to the bus 515, but may also be connected by other interface and bus structures, such as the communications module(s) 532 and wired port(s) 540. Motion detection 552 can be used to determine gestures made with the device 500.
A user may communicate with other users via speaking into the microphone 542 and via text messages that are entered on the key pad 541 or a touch sensitive display 543, for example. The audio unit 555 may provide electrical signals to drive the speaker 544 as well as receive and digitize audio signals received from the microphone 542.
The mobile device 500 may include a video unit 560 that provides signals to drive a camera 561. The video unit 560 may also receive images obtained by the camera 561 and provide these images to the processing unit 505 and/or memory included on the mobile device 500. The images obtained by the camera 561 may comprise video, one or more images that do not form a video, or some combination thereof.
The communication module(s) 532 may provide signals to and receive signals from one or more antenna(s) 565. One of the antenna(s) 565 may transmit and receive messages for a cell phone network. Another antenna may transmit and receive Bluetooth® messages. Yet another antenna (or a shared antenna) may transmit and receive network messages via a wireless Ethernet network standard.
Still further, an antenna provides location-based information, e.g., GPS signals to a GPS interface and mechanism 572. In turn, the GPS mechanism 572 makes available the corresponding GPS data (e.g., time and coordinates) for processing.
In some embodiments, a single antenna may be used to transmit and/or receive messages for more than one type of network. For example, a single antenna may transmit and receive voice and packet messages.
When operated in a networked environment, the mobile device 500 may connect to one or more remote devices. The remote devices may include a personal computer, a server, a router, a network PC, a cell phone, a media playback device, a peer device or other common network node, and typically includes many or all of the elements described above relative to the mobile device 500.
Aspects of the subject matter described herein are operational with numerous other general purpose or special purpose computing system environments or configurations. Examples of well known computing systems, environments, and/or configurations that may be suitable for use with aspects of the subject matter described herein include, but are not limited to, personal computers, server computers, hand-held or laptop devices, multiprocessor systems, microcontroller-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
Aspects of the subject matter described herein may be described in the general context of computer-executable instructions, such as program modules, being executed by a mobile device. Generally, program modules include routines, programs, objects, components, data structures, and so forth, which perform particular tasks or implement particular abstract data types. Aspects of the subject matter described herein may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
Furthermore, although the term server may be used herein, it will be recognized that this term may also encompass a client, a set of one or more processes distributed on one or more computers, one or more stand-alone storage devices, a set of one or more other devices, a combination of one or more of the above, and the like.
While the invention is susceptible to various modifications and alternative constructions, certain illustrated embodiments thereof are shown in the drawings and have been described above in detail. It should be understood, however, that there is no intention to limit the invention to the specific forms disclosed, but on the contrary, the intention is to cover all modifications, alternative constructions, and equivalents falling within the spirit and scope of the invention.
The present application claims priority to U.S. provisional patent applications Ser. Nos. 61/442,701, 61/442,713, 61/442,735, 61/442,740 and 61/442,753, each filed Feb. 14, 2011 and hereby incorporated by reference. The present application is related to U.S. patent applications attorney docket nos. 332296.02, 332297.02, 332339.02 and 332340.02, assigned to the assignee of the present invention, and hereby incorporated by reference.
Number | Date | Country | |
---|---|---|---|
61442735 | Feb 2011 | US | |
61442701 | Feb 2011 | US | |
61442713 | Feb 2011 | US | |
61442740 | Feb 2011 | US | |
61442753 | Feb 2011 | US |