So, I’ve got a dual-core phone and because of the way Android works I’m also, it seems, forced to use two threads to run my game in. For the moment. I might figure out some way around that.
My problem is that the producer-consumer relationship between the logic thread and the rendering thread seems to be very vague. I don’t know if it’s the Android thread scheduler (which should be just plain ol’ Linux thread sheduling) or what, but the actual length of time spent in the meat of the logic thread and the rendering thread can vary by a factor of up to 3 on the same data each frame. The only thing that can slow it down is a synchronized block waiting for a render queue to become available to write to or read from, and thusly I surmise that the way that the thread scheduler wakes up from this is what’s causing the latency (after all it only takes a 30ms delay to effectively double the time any particular unit of work is going to take!).
Has anybody got any ideas as to how I can get this idea of writing to one queue and reading from another queue to work without the random latencies?
Shall I just give up on dual-core efficiency and do the logic in the rendering thread? (After all there’s not that many phones with dual cores)
Cas