Control the VP environment
The routine manager executes your C UDR in a virtual-processor (VP) environment.
- The current VP
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 VP class to which the current VP belongs
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 code uses advanced operating-system calls.
For more information, see Avoid restricted system calls.
- The code performs some other task that is ill-behaved.
For more information, see Preserving availability of the CPU VP and Write threadsafe code.
- The code is written in C++.
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.
- In a user-defined VP class
- Locked to one VP or VP class
- As a separate process
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() |