Multi-threaded DSOM programs

In a system that supports multi-threading, like OS/2, the easiest way to write a peer DSOM program is to dedicate a separate thread to perform the usual "server" processing. This body of this thread would contain the same code as the simple servers described in section 6.4, "Basic Server Programming."

DSOM_thread(void *params)
{
   Environment ev;
   SOM_InitEnvironment(&ev);

/* Initialize the DSOM run-time environment */
   SOMD_Init(&ev);

/* Retrieve its ImplementationDef from the Implementation
   Repository by passing its implementation ID as a key */
   SOMD_ImplDefObject =
      _find_impldef(SOMD_ImplRepObject, &ev, *(ImplId *)params);

/* Create SOM Object Adapter and begin executing requests */
   SOMD_SOMOAObject = SOMOANew();
   _impl_is_ready(SOMD_SOMOAObject, &ev, SOMD_ImplDefObject);
   _execute_request_loop(SOMD_SOMOAObject, &ev, SOMD_WAIT);
}

Note: The DSOM run time is "thread safe"; that is, DSOM protects its own data structures and objects from race conditions and update conflicts. However, it is the application's responsibility to implement its own concurrency control for concurrent thread access to local shared application objects.