How does coding for an alarm clock work?

Jul 20, 2001
55,208
1,876
126
#1
I noticed that the battery on my iPhone drains faster if I set the alarm clock. Does a script constantly check to see if it’s time to ring the alarm?
 

Steelbom

Senior member
Sep 1, 2009
280
0
76
#2
I've done a fair bit of programming, a bit on iOS in particular. I don't really know the answer, but it doesn't seem likely that the alarm clock will drain your iPhone (noticeably) faster. I suspect the app would be checking the time periodically but again, not so much that it should hurt battery life in any noticeable way.
 

KentState

Diamond Member
Oct 19, 2001
7,529
42
91
#3
Just a guess, but an alarm could be a thread that is asleep. The CPU will continue to run cycles regardless and wake the thread when it's time to go off. Since the pooling rate to wake the thread is pretty low, the CPU consumes power mostly for active tasks. A button press or anything else to wake the screen is similar in that it's pooling for an event.

If you think about it, a phone CPU might be running at 100Mhz minimum. Even then that's 100 million cycles per second that can go somewhere. Checking if a thread should wake is a very small amount of that.
 

ASK THE COMMUNITY

TRENDING THREADS