Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
February 16, 2019
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
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

Boston Dynamics
Boston Dynamics — Waltham, Massachusetts, United States

Software Engineer
Wargaming Sydney
Wargaming Sydney — Broadway, New South Wales, Australia

Gameplay Programmer, C++ - Vehicle Physics
Skydance Interactive
Skydance Interactive — Marina Del Rey, California, United States

Lead Engineer
The Behemoth
The Behemoth — San Diego, California, United States

Experienced Network Programmer

Loading Comments

loader image