Skip to content

Multithreaded concept

malex984 edited this page Sep 28, 2012 · 23 revisions

Multi-library concept:

  • 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
  • the rest of our libs: libpolys, kernel, Singular (numeric?) should make use of the above "Multi-library concept":
    1. identify all the global variables
    2. Document all readonly global variables (with a single global initialization)
    3. Guard shared ones with locks if they are not readonly vars.
    4. 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?