It's quite obvious that Microsoft's big focus for Windows 8 is to make it a more suitable operating system for the rapidly growing tablet and touch segment. Through Metro style apps, Microsoft will be imposing a strict set of rules to ensure that Windows 8 on portable devices will be as battery-friendly as possible.
Windows 8's Metro apps take a big page out of how modern mobile operating systems handle background tasks. In a recent B8 blog post, Microsoft explained that Metro style apps can be in one of three possible states:
- Actively running in the foreground
- Suspended in the background
- Performing some defined background activity
Active foreground apps utilize CPU, disk, memory, and other resources as needed. This isn't much different from how desktop applications work. The real shift from how things are done on desktop operating systems comes when an app is no longer in the foreground but still has functionality in the background.
Windows 8's Metro apps will suspend in the background, not unlike how Apple decided to implement multitasking in iOS. As soon as a user switches away from an app, the operating system completely suspends all actions, but still holds its state in memory for instant resume when it's switched back.
"This means that the Windows scheduler (the component that schedules CPU access for processes and threads) does not include it in the CPU scheduling," Microsoft's lead program managers wrote in the blog. "Since the operating system is not scheduling the app, the app is not using the CPU, and it is possible for the CPU to drop into lower power states. Getting the CPU into low power states can be critical to achieving better battery life.
"The benefit of being able to suspend apps is that you get really fast switching between them without negatively impacting the battery life or performance of your system. This is altogether different than traditional desktop apps, where we are all used to optimizing our workflow for those apps that take a long time to launch."
Since memory is an unfortunately finite resource, there will be times when suspended apps will have their saved memory states wiped off the slate. Microsoft says that this should be a rare occurrence since memory can also be overflowed into local storage.
"The system may remove an app from the suspended state and terminate the app if the system starts to run low on memory. Memory is a finite resource and we want the apps you are using most frequently to be ready for you instantly," notes the blog. "If you have not used an app in a while and the operating system needs more memory, it terminates one of your suspended apps. This should happen relatively infrequently because the memory manager will take your suspended apps and save them to disk (which generally has more capacity than physical memory). When you switch back to these apps, they will be ready instantly."
Of course, there are cases where a complete suspension of all app functionality would be undesirable, such as if it were in the middle of a file copy function or if it were streaming music. For these cases, Microsoft has defined certain functions that may remain active in the background in WinRT:
- Playing music
- Downloading a file from or uploading it to a website
- Keeping live tiles alive with fresh content
- Receiving a VoIP call
- Receiving an instant message
- Receiving an email
- Sharing content (like uploading photos to Facebook)
- Synchronizing content with a tethered device (like syncing photos)
Finally, there's one more new state of Windows 8 in the interest of connectivity and battery life: connected standby. In this mode, desktop apps will be in a sleep state while Metro style apps can use a minimal set of resources to stay updated.
"This enables some great connected scenarios, such as always having email up-to-date, and being able to receive instant messages or phone calls, while still delivering amazing battery life," Microsoft explained.
Stay tuned for more on Windows 8.