Wednesday, June 28, 2006

Multi-Thread Synchronization vs. Real-Time

When dealing with multi-threading, some of ue are confused by real-time and thread synchronization. Sometimes we are not sure about which we need in our applications.

By real-time, I mean that the simulation time your program completes should go hand-in-hand with your wall clock, no faster nor slower. Let's say you're simulating the traffic on a highway. If you want to simulate traffic for a period of one second, then your program should complete that one-second simulation within one second time. Only this way you can acheive real-time. Multiple CPUs can help to acheive real-time through better parallelism. But if the computation is very simple, one CPU can do the job too. As you may notice now, parallelism is not a necessity in pursuing real-time, as lon as you can catch up the wall clock.

Synchroniztion is a different issue. It is about the collaboration between two threads. It has nothing to do with how fast or slow your CPU is. You don't need multiple or faster CPUs to acheive synchronization. One of the major purposes for synchronization is protecting resources shared by more than one thread.

0 Comments:

Post a Comment

<< Home