forked from Singular/Singular
-
Notifications
You must be signed in to change notification settings - Fork 0
Multithreaded concept
malex984 edited this page Oct 1, 2012
·
23 revisions
- Some of our libraries need their own TLS
- xthread should provide the basic support for C++:
- Common TLS Structure that accommodates places for all of our libs: void* lib_tls[MAXLIBID] = 0,0,0...0;
- Common TLS macros for getting at it
- new_thread, which should take Init and Done as well as run function pointers for setting up TLS for all the needed Libs: in their dependency order!
- LIBIDs as #define's
Small steps (plan):
- Start with SW
- Make sure findexec is used readonly and thus is thread-safe
- Cristian makes his variant of omalloc - thread-safe
- since factory is not thread-safe and uses NTL - guard all the calls into factory with a lock: TODO for a HiWi, this should better be ifdef'ed depending on HAVE_THREADS(!?)
- the rest of our libs: libpolys, kernel, Singular (numeric?) should make use of the above "Multi-library concept":
- identify all the global variables
- Document all readonly global variables (with a single global initialization)
- Guard shared ones with locks if they are not readonly vars: examples?
- The rest should be put into LIBTLS Structure for that lib. - but first we simply assume that we have "__thread" and mark them with this directive, maybe using a conditionaly defined macro __THREAD, depending on HAVE_THREADS. Examples: currRing, options (value/test)...
- Each lib should provide its own Init/Done_lib global functions that are supposed to know about corresponding functions for underlying libraries, and should call them in correct order: easy with the left libraries(?)
- Each library should have its own TLS macro and access thread local variables via: TLS().variable