You can define special classes of virtual processors to run user-defined routines or to run a DataBlade module. User-defined routines are typically written to support user-defined data types. If you do not want a user-defined routine to run in the CPU class, which is the default, you can assign it to a user-defined class of virtual processors (VPs). User-defined classes of virtual processors are also called extension virtual processors.
This section provides the following information about user-defined virtual processors:
You can specify as many user-defined virtual processors as your operating system will allow. If you run many UDRs or parallel PDQ queries with UDRs, you should configure more user-defined virtual processors.
User-defined classes of virtual processors protects the database server from ill-behaved user-defined routines. An ill-behaved user-defined routine has at least one of the following characteristics:
A well-behaved C-language UDR has none of these characteristics. Execute only well-behaved C-language UDRs in a CPU VP.
To ensure safe execution, assign any ill-behaved user-defined routines to a user-defined class of virtual processors. User-defined VPs remove the following programming restrictions on the CPU VP class:
Functions that run in a user-defined virtual-processor class need not yield the processor, and they might issue direct file-system calls that block further processing by the virtual processor until the I/O is complete.
The normal processing of user queries is not affected by ill-behaved traits of a C-language UDR because these UDRs do not execute in CPU virtual processors. For a more detailed discussion of ill-behaved routines, refer to the IBM Informix DataBlade API Programmer's Guide.
The VPCLASS parameter with the vpclass option defines a user-defined VP class. You also can specify a nonyielding user-defined virtual processor. For more information, see Specifying VPCLASS and the configuration parameters chapter of the IBM Informix Dynamic Server Administrator's Reference.
The SQL CREATE FUNCTION statement registers a user-defined routine. For example, the following CREATE FUNCTION statement registers the user-defined routine, GreaterThanEqual(), and specifies that calls to this routine should be executed by the user-defined VP class named UDR:
CREATE FUNCTION GreaterThanEqual(ScottishName, ScottishName) RETURNS boolean WITH (CLASS = UDR ) EXTERNAL NAME '/usr/lib/objects/udrs.so' LANGUAGE C
To execute this function, the ONCONFIG file must include a VPCLASS parameter that defines the UDR class. If not, calls to the GreaterThanEqual function will fail.
To configure the UDR class, include a line similar to the following one in the ONCONFIG file. This line configures the UDR class with two virtual processors and with no priority aging.
VPCLASS UDR ,num=2,noage
The preceding line defines the UDR VP class as a yielding VP class; that is, this VP class allows the C-language UDR to yield to other threads that need access to the UDR VP class. For more information on how to use the VPCLASS configuration parameter, see the IBM Informix Dynamic Server Administrator's Reference.
For more information on the CREATE FUNCTION statement, refer to the IBM Informix Guide to SQL: Syntax.
You can add or drop virtual processors in a user-defined class while the database server is online. For instructions on how to do this, refer to Adding Virtual Processors in Online Mode and Dropping CPU and User-Defined Virtual Processors.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]