Modules | |
XIO Driver Programming | |
Driver Programming: String options |
Globus XIO introduces a notion of a driver stack to its API. With in globus_xio every IO operation must occur on a globus_xio handle. Associated with each handle is a stack of drivers. A driver is a module piece of code that implements the globus_xio driver interface. The purpose of a driver is manipulate data passed in by the user in someway. Each driver in a stack will serve its own unique purpose.
IO operations pass from driver to driver, starting at the top of the stack and ending at the bottom. When the bottom layer driver finishes with the operation it signals globus_xio that it has completed. Completion notification then follows the driver stack up to the top.
Transport driver:
A transport driver is one that is responsible for actually putting bytes onto the wire. For example: A TCP driver or a UDP driver would be an example of transport drivers.
Per driver stack there must be exactly one transport driver and must be at the bottom of the stack. A transform driver is defined by its lack of passing an operation to the next driver in the stack. This type of driver does not rely on globus_xio for further completion of an operation, rather it is self sufficient in this task.
Transform driver:
The Globus XIO Driver API is a set of functions and interfaces to allow a developer to create a back-end driver for globus_xio. To create a driver the user must implement all of the interface functions in the driver specification. There are also a set of functions provide to assist the driver author in implementation.
For basic driver needs, the user will have to pay attention to a few new structures and concepts.
globus_xio_operation_t
This structure represents a request for an operation. If the driver can service the operation it does so and the calls the appropriate finish_operation() function. If the driver cannot completely service the operation it can pass() it along to the next driver in the stack. As soon as the operation structure is either finished or passed it is no longer valid for use in any other function.
globus_xio_driver_handle_t
A driver_handle represents a open handle to the driver stack for xio. The driver obtains a driver_handle by calling globus_xio_driver_open(). When the open operation completes (it callback is called) the driver then has a driver_handle. The driver_handle allows the user to do some complex things that will be described later.
globus_xio_stack_t
Open
globus_xio_driver_open_t is called. The user calls globus_xio_driver_open() passing it the operation and the stack and a callback. When the open callback is called the driver is given a new operation as a parameter. The driver will then call globus_xio_driver_finished_open() passing it the now initialized driver_handle and the newly received operation.
The call to globus_xio_driver_finished_open() does two things:
Read/Write
The read or write interface function is called. It receives a operation as a parameter. The driver then calls the appropriate pass operation and waits for the callback. When the callback is received the driver calls finished_operation passing in the operation structure it received in the callback
Close
The typical driver implementation is describe above. However globus_xio allows driver authors to do more advanced things. Some of these things will be explored here.
Read Ahead
Once a driver_handle is open a driver can spawn operation structures from it. This gives the driver the ability to request io from the driver stack before it receives a call to its own interface io interface function. So if a driver wishes to read ahead it does the following:
Pre-Opening Handles