The routine manager executes your C UDR in a virtual-processor (VP) environment. The VP environment consists of a VP and VP class, as follows:
When a C UDR executes, it runs on a particular virtual processor called the current VP, which has an ID number from 1 to MAXVPS. A current VP is an active VP; that is, it is currently performing some task. The task that the active VP performs depends on the VP class to which it belongs. For example, a CPU VP can execute SQL statements and well-behaved UDRs. A user-defined VP executes those UDRs that are assigned to it (with the CLASS routine modifier of the CREATE FUNCTION or CREATE PROCEDURE statement).
The UDR specifies its VP class with the CLASS routine modifier when it is registered. If the CREATE FUNCTION or CREATE PROCEDURE statement omits the CLASS modifier, the UDR executes in the current active VP class.
The following traits of C UDRs are common reasons for needing to control the VP environment:
For more information, see Avoiding Restricted System Calls.
For more information, see Preserving Availability of the CPU VP and Writing Threadsafe Code.
All C++ code has the potential to not follow the memory management rules for well-behaved code. The most serious violation of these rules is the use of static virtual function pointers in C++ classes.
If the source code is not available to change the UDR so that it is well-behaved, the only solution is to isolate the code execution from the CPU VP class. Possible execution scenarios include executing:
The DataBlade API provides the following functions to enable UDRs and DataBlade modules to examine their VP environment and to control portions thereof.
VP-Environment Information | DataBlade API Function |
---|---|
Obtain information about the current VP environment from within a UDR | mi_vpinfo_classid( ),
mi_vpinfo_isnoyield( ), mi_vpinfo_vpid( ) mi_class_id( ), mi_class_maxvps( ), mi_class_name( ), mi_class_numvp( ) |
Lock the UDR to a VP environment | mi_module_lock( ),
mi_udr_lock( ) |
Change the VP environment in which a UDR executes | mi_call_on_vp( ),
mi_process_exec( ) |