Power to the People

In 2002 when we released our first Smartphone OS, there were quite a few fundamental differences between the Smartphone and the PocketPC.  Since then, we've been working to unify the platforms.  In WM5, we did a bunch of plumbing work to this end, and brought Softkeys and Persistent Storage to PocketPC.  At this point, the two biggest differences in the platforms are the PocketPC touch screen and the wildly different power models the two platforms use.  In this blog entry, I'm going to talk about those power models and what they mean to users.  I'll follow up with a second entry that talks about what this means to ISV developers.

You are getting very sleepy...
It all comes down to this: PocketPCs sleep, and Smartphones don't.  Smartphones have a model that's very easy to understand.  The device can be on, or it can be off.  When it's on, everything works.  When it's off, nothing does.  When it's off, you can't receive phone calls, you don't get meeting reminders, and nothing is burning power.  You can pull out the batteries and have no detrimental effects.  (Okay I'm stretching the truth a bit here.  Many phones use a tiny bit of charge to keep a clock going so that you don't need to reset the time every time you pull out the batteries.) 

The PocketPC model is much harder to explain.  It can be on, it might be able to be off, and it can be somewhere in between.  A purist will call that in between state "suspended" but I like to anthropomorphize my devices, and "sleep" is more catchy.  When the device is asleep, the screen is off, and programs aren't running.  In fact, by and large, programs don't even know that the system went to sleep.  We never tell them, and we expect them to act as though it never happened.  While the PocketPC was asleep, they just didn't run. 

Still, while the system is asleep, there are a few things that keep working, and those things can wake the system back up.   For instance, the power button works.  And an incoming phone will wake the system up.  So will a meeting reminder.  Applications have the ability to say, "Run me at this time, and wake the system up to do it if you have to."  If you've ever had your PocketPC turn on in your pocket, it was a result of something deciding it was time to wake up, even though you didn't want it to.  (Yes, that annoys me too.)

Sleep is the main way that PocketPCs conserve power.  So the PocketPC is always trying to fall asleep.  He's like a bored security guard on the graveyard shift staring at a TV screen with his eyes drooping, only to jolt himself back awake every few minutes.  In Settings you get to tell your PocketPC how long to stay awake.  Three minutes is typical.  And then you've got to actively work to keep him up.  If three minutes go by without you pressing any buttons or touching the screen, he'll fall back to sleep.  (You can put him right to sleep by pressing the power button.)  Apps that want to keep him awake longer need to be proactive about it.  There's a function apps call (SystemIdleTimerReset) every 30 seconds when they want the system to stay awake.  This is how Media Player keeps the music playing for longer than three minutes.  This is also how Active Sync can make sure it syncs everything.  And this is how PIE can download huge files without the system falling asleep in the middle of them.  Etc.

But wait, it gets even more complicated than this.  What happens when the system wants to wake up briefly to do something (like keep your email up to date) but doesn't want to bother you about it?  (There was a time when the PocketPC turned on at midnight and shined its backlight all over your bedroom, thus waking you up with him.  Now he's smart enough to not turn the backlight on for his midnight excursions.)  There's a semi-lucid state between Sleep and On called "Unattended."  In Unattended, the system is running, but the screen and backlight are off.  Unattended is how ActiveSync keeps your email up to date without turning the device on in your pocket. 

PocketPCs generally don't have a button you can press to turn them all the way to Off.  But if you pull out the batteries (because of Persistent Storage, more WM5 devices will have removable batteries), they'll turn Off completely.  By and large, however, when the device seems to be "Off," he's really just asleep.

That guy must drink a lot of coffee...
As I said before, things are much simpler in the Smartphone world.  Smartphones follow a model we call "Always On."  These guys never sleep.  You can turn them off completely, but when you do that, you don't expect to receive phone calls (at least, I hope you don't.  You'll be disappointed otherwise).  Sure, if you don't touch any keys for a bit, the backlight will turn off.  And if you don't touch any keys for a while longer, the screen will turn off.  And with the screen off, he looks asleep.  But he's not.  He's just resting his eyes.  Programs are still running, and everything is still going.

This is simpler for everyone involved.  Users don't need to understand the differences between On, Off, Sleep and Unattended.  And apps don't need to frequently call SystemIdleTimerReset to keep things going.  We've written all of our Smartphone apps to use the CPU as little as possible.  If you're not actively using the device, then nothing runs 99.9% of the time.  And our OEMs have written code that makes the CPU go into an extremely low power mode whenever there's nothing for it to do.  When the phone is sitting there idle, it's using just barely more power than a sleeping PocketPC.

But there's a drawback.  Badly written apps can do very bad things to your battery life.  Say you've got a cute little app that has an image of a kitty that jumps around and waves to you.  And, say that animation makes the CPU run just 1% of the time.  You've got the device sitting on your desk overnight, with the screen off, and this darned kitty desperately trying to get you to look at it, even though you're in bed and uninterested.  The animation just cut your standby time to one tenth of what it would have been without it.

In my next blog entry, I'll tell developers how not to destroy your battery life.  But, users, if you've got apps that run animations forever, get rid of them.  Yes, the PocketPC sleep would have protected you from these apps.  (Remember that apps don't run while a PocketPC is sleeping.)  But, even on a PocketPC, if you've got an app that's burning power unnecessarily, it's probably not an app you want.

Note that the problem here is apps which use the CPU when you're not using the phone.  Doing animations and such while you're interacting with the app is fine.  If you're playing a game, the backlight is on.  The backlight is burning a ton more power than the CPU is.  But when you stop playing, that game better stop too.

Mike, what are you smoking?
The PocketPC "Sleep" model has been around since the dawn of time.  Okay, well, at least since the dawn of Windows CE.  So why did Smartphone change it?  You're going to find this hard to believe, but in a connected world, the Always On model actually burns less power than the Sleep model.  Yes, you read that correctly.  Staying on all the time actually burns less power than going to sleep.  Here's why.

The issue is that it takes a "long" time to go to sleep and a similarly long time to wake back up.  When a PocketPC goes to sleep, we have to notify every device driver so that they can each save any important information (their "state") and shut off the hardware they're controlling.  Then, on wake up, we need to notify every driver again and have them turn all their hardware on.  This process can take up to three seconds in each direction. 

Smartphone, on the other hand, can come out of his idle in a millisecond, do what he needs to do, and go back to idle a millisecond after he's done.

Imagine that your device receives a SMS message.  The sleeping PocketPC will need to run the CPU for around six seconds to handle it.  The Smartphone will do the same task in a few milliseconds.  Waking up is much more efficient on a device that doesn't sleep.  It turns on only the devices necessary, uses them for the minimum amount of time needed, and then immediately shuts them back off. 

Now, imagine a device that gets an SMS every time it moves from one cell tower to another, and imagine being in an area where you're on the boundary between two towers.  Or, consider being signed in to an Instant Messenger client and having it frequently updating your friends list.  Or, imagine a process that downloads data you care about every few minutes.  Etc.  As these things become more pervasive, we'll see the Always On power model being much more energy efficient than the sleep model. 

In Windows Mobile 5, the PocketPC still uses the original Sleep power model.  In some future version (maybe the next, maybe the one after that, we don't know yet) PocketPCs will move to the Smartphone Always On model.  And then the touch screen will be the one big difference between them.

Mike Calligaro