Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
May 26, 2017
arrowPress Releases






If you enjoy reading this site, you might also want to check out these UBM Tech sites:


The nightmare of getting time at the low level on Android
The nightmare of getting time at the low level on Android Exclusive
June 6, 2012 | By Staff

June 6, 2012 | By Staff
Comments
    6 comments
More: Smartphone/Tablet, Programming, Exclusive



In Gamasutra's latest technical feature, XS2theWorld senior developer Sergio Giucastro examines the problems that game developers can encounter when trying to get time at the low level on Android devices.

Giucastro points out that modern mobile platforms have extremely accurate hardware timers. "For example, ARM CPUs like the Cortex A9 (Samsung Galaxy SII) has a 64-bit Global Timer Counter Register -- that is a really accurate monotonic, non-decreasing clock, cheap to read."

According to the Cortex A9 ARM Cycle Timing document, using the LDM instruction takes only one CPU cycle. You can use the exact same concept on the Tegra platform using reading memory mapped RTC (Real Time Clock) registers, too.

"Timing using the Time Stamp Counter is really fast, but on some platforms it can be dangerous as well," notes Giucastro. "In [the] case of multi-core systems, or during the low frequency/CPU saving state of the system, it may lead to errors. You should beware this, and calibrate it with the PIT on some systems."

He adds, "The nightmare begins when you realize that different platforms have different kind of RTC, and that besides this, a lot of different hardware clocks exists in modern platforms: Time Stamp Counter, Programmable Interval Timer, High Precision Event Timer, ACPI PMT."

Giucastro says that direct hardware access means writing primitives specific to a single platform. "Furthermore, developing ASM code takes more time, is not portable, and is difficult to read for most developers. Finally, the OS can raise an exception if the hardware resource you are trying to access requires supervisor/kernel mode."

The full feature, in which Sergio Giucastro goes more into depth on getting the most accurate, least resource-intensive timing calls on the Android platform, is live now on Gamasutra.


Related Jobs

Telltale Games
Telltale Games — San Francisco, California, United States
[05.25.17]

Telltale Engineering Meetup
Disruptor Beam
Disruptor Beam — FRAMINGHAM, Massachusetts, United States
[05.25.17]

Senior Data Analyst
Intrepid Studios Inc
Intrepid Studios Inc — San Diego, California, United States
[05.24.17]

Associate Programmer
Heart Machine
Heart Machine — Culver City, California, United States
[05.24.17]

Graphics Engineer









Loading Comments

loader image