CPU virtual-processor class
The CPU virtual-processor class is the primary VP class of the
database server. It runs the following kinds of threads:
- All session threads
Session threads process requests from the SQL client applications.
- Some internal threads
Internal threads perform services internal to the database server.
The CPU VP class is the default VP class for a UDR. You do not need to specify the CLASS routine modifier in the CREATE FUNCTION or CREATE PROCEDURE statement to have the UDR execute in the CPU VP class.
SPL routines must always run in the CPU VP. Therefore, you do not
need to specify the CLASS routine modifier for an SPL routine. The
following CREATE FUNCTION statement registers the getTotal() SPL
routine, which runs in the CPU VP:
CREATE FUNCTION getTotal(order_num, state_code)
RETURNS MONEY
...
END FUNCTION
You cannot run an SPL routine in a user-defined VP.
By default, a C UDR runs in the CPU VP class. Generally, UDRs perform
best in the CPU VP class because threads do not have to migrate among
operating-system processes during query execution. However, to run
in the CPU VP, the C UDR must be well behaved; that is,
it must adhere to the following programming requirements:
- Preserves concurrency of the CPU VP
- Yields the CPU VP for intense calculations
- Does not perform blocking operating-system calls
- Is thread safe:
- Does not modify static or global data
- Does not allocate local resources
- Does not modify the global VP state
- Does not make unsafe operating-system calls
Important: Use the CPU VP with caution. If a UDR
contains errors or does not adhere to these guidelines, this routine
might affect the normal processing of other user queries.
You can relax some of these programming requirements if you run your C UDR in a user-defined VP class. For more information, see User-defined virtual-processor class (C).