HP OpenVMS Systems

ask the wizard
Content starts here

Meaning of Thread Safe?

» close window

The Question is:

It is oft-stated that many of the VMS runtime libraries are not "thread safe."
 I'm looking for clarification on this.
If I call the CONV$ routines to perform a simple file copy operation from the
 default (initial) thread created by VMS for my application, it works
 correctly.  If I make the identical call from within a thread created by my
 application with pthread_create(
), the call to CONV$CONVERT crashes with ACCVIO, signalled from within the
 bowels of PTHREAD$RTL, with CONV$SHR above it in the call chain.
Here is the called function that is run from the thread:
    int convert_test()
        long sts;
        $DESCRIPTOR( dsc$in, "input.dat" );
        $DESCRIPTOR( dsc$out, "output.dat" );
        sts = conv$pass_files( &dsc$in, &dsc$out );
        if( !$VMS_STATUS_SUCCESS( sts ))
            lib$stop( sts );
        sts = conv$pass_options();
        if( !$VMS_STATUS_SUCCESS( sts ))
            lib$stop( sts );
        sts = conv$convert();
            if( !$VMS_STATUS_SUCCESS( sts ))
            lib$stop( sts );
        return sts;
There are not multiple threads calling CONV$ at the same time; only a single
 instance calling from within an application-created thread (linked with
 threads and upcalls enabled).
When Compaq says runtimes are not "thread safe" does this imply that they
 cannot be run from a thread at all (i.e. the execution environment of a thread
 is incompatable with the runtime in some way) or just that multiple threads
 using the runtime simultan
eously are at risk?
It would appear that for CONV$ at least, the answer is that the runtime
 environment of a thread is incompatable with the runtime?  Or is this a "bug"
 in the CONV$ code that could be fixed -- I really want to use the service, and
 *promise* not to call it f
rom more than one thread at a time...

The Answer is :

  "thread safe: Refers to a routine that can be called simultaneously
  from multiple threads without risk of corruption. Refers to a library
  that typically consists of routines that do not themselves create or
  use threads but which can be called safely from applications that use
  Also see:
  In this case, the OpenVMS Wizard would guess that the ACCVIO has little
  or nothing to do with thread safety, but may be due to insufficient stack
  space or potentially with the use of ASTs.  Try increasing the size of the
  thread stack, and check for AST activity in the main thread.
  Related topics include (1661), (2681), (4647), and (6984).

answer written or last revised on ( 7-SEP-2001 )

» close window