Harmony
  1. Harmony
  2. HARMONY-3090

Create a new table based API for thread library functions

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None
    • Patch Info:
      Patch Available
    • Estimated Complexity:
      Advanced

      Description

      Both DRLVM and the IBM VME maintain their own implementations of the hythr shared library (not always named hythr). This leads to a situation where the VM is linked against one of the shared libraries and the classlib is linked against another. The internal implementation of hythr assumes a certain amount of coordination between the threading functions. For the most part this does not lead to problems when things aren't co-ordinated. However there have been issues.

      One such issue would involve thread local storage (TLS). The Harmony implementation of TLS uses static variables as the basis for its implementation. Those statics are confined on a shared library basis. Meaning that if a TLS value was being set when the VM called a thread lib function, a call to a thread lib function from the classlib would not see that TLS data. This is due to the VM and classlib using different thread library shared libraries.

      The above is the case when the shared libraries contain the same implementation. A similar scenario arises when the shared libraries for threading do not contain the same implementation.

      The thread library used by the VM, for example, could be relying on some storing values in TLS that will modify the behaviour of other calls to thread library functions. When the classlib calls it's own implementation of thread library functions, the behvaiour of those functions will not be modified by the values set in TLS by the VM. This could lead interesting hard to diagnose failures in the runtime as a whole.

      A solution to these problems would be to create a standard thread API, much like the one created for the port library.

      The VM would become responsible for providing the hythr shared library. The classlib (and other tools that use threading functions) would compile against the API and no-opt implementation of hythr.

      The attached patch is one possible implementation of this idea. It creates a thread library table (HyThreadLibrary) much like the port library table. The thread library is created by the port library during the port library's initialization. The thread library can be obtained from the port library using the new port_get_thread_library() function.

      Also, the VMI has been extended to include a new GetThreadLibrary() function. Alternatively, we could leave the VMI as is and modify the following defines in hythread.h to:
      #define THREAD_ACCESS_FROM_VMI(vmi) HyPortLibrary *privatePortLibraryForThread = (*vmi)->GetPortLibrary(vmi); \
      HyThreadLibrary *privateThreadLibrary = privatePortLibraryForThread ->port_get_thread_library(privatePortLibraryForThread)

      THREAD_ACCESS_FROM_ENV and THREAD_ACCESS_FROM_JAVAVM would need to be modified in a similar way.

      1. thread_api_harmony_patch_20070206.txt
        314 kB
        Ronald Servant
      2. thread_api_harmony_patch_20070130a.txt
        286 kB
        Ronald Servant
      3. launcher_02052007_patch.txt
        29 kB
        Ronald Servant
      4. harmony-3090-as-an-option.diff
        79 kB
        Mark Hindess

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Mark Hindess
              Reporter:
              Ronald Servant
            • Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:

                Development