[DGD]Thread Local Storage
Felix A. Croes
felix at dworkin.nl
Sat Nov 6 00:25:51 CET 1999
What is thread local storage?
There are variables which are unique within the mud, and which can be
kept in a central object. Thus, for example, has this_player() been
implemented in the 2.4.5 simulation. However, once multi-processor
support is enabled in DGD a variable in an object which is modified
in every thread -- such as this_player(), which is kept as a
variable in /dgd/sys/global -- would effectively undo most of the
advantages of running threads in parallel (for the details on why,
I refer to my previous postings on the subject of multi-processor
support; they're in the mailing list archive).
The solution is thread local storage, which exists only for as long
as the current thread -- usually started by receiving a message or a
callout -- is active. Thread local storage exists only on the stack,
not in an object. By inheriting /kernel/lib/api/tls, objects can
access values in thread local storage, or even change the size of the
thread local store.
TLS is implemented using a trick: the value returned by call_trace()
includes the arguments to all functions. The kernel lib ensures
that the first argument to the second function in the trace is
always an array, which can be retrieved from the trace and
accessed directly. By inheriting /kernel/lib/api/tls, this can
be done safely and efficiently.
Regards,
Dworkin
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list