> Now how do you go about performing an atomic operation in MT? I > understand the desire for reentrance via the exclusive use of local > variables, but I'm not quite sure how you can enforce this when many > operations are on shared data (manipulating elements of the > interpreter / global variables).
There are two categories of global vars: ones used by runtime and ones used by app. For former, the runtime will use following schemes: 1) Reducing globals by using more per-thread variable (such as per thread profile info instead of per interpreter info). 2) Use atomic variable. Increment a profile counter does not need lock even it may ocationally corrected by one. 3) Use mutex as needed. > I definately agree that locking should be at a high level (let them core > if they don't obey design it well). I liked the perl5 idea that any > scalar / array / hash could be a mutex. Prevents you from having to > carry around lots of extra mutex-values. We can achieve the exact > same "synchronization" policy of java or one that's finer > tuned for performance. We can either let sv/av/hv carry mutex, or let them be atomic, although it is non-trivial to make them atomic. For languages like Smalltalk, it is trivial to make system atomic, since all complex data structure are user defined. Hong