| United States-English |
|
|
|
![]() |
HP-UX SNAplus2 API NOF Programmer's Guide: HP-UX 11.0, 11i v1, and 11i v2 > Chapter 2 Writing
NOF ApplicationsScheduling Asynchronous Events |
|
The method that an application uses to schedule asynchronous events depends on which of the following types of application it is:
To schedule asynchronous events, single-threaded applications can use either the application scheduling mode or the signal-based scheduling mode. Application scheduling mode gives the application full control over event scheduling from different sources by integrating SNA callbacks with the application's main processing loop. The application calls an SNA event handler entry point in the SNA library when work is available for the library to process, and the handler makes the necessary callbacks to the application.
To receive notification of SNA events, the application accesses the file descriptor on which SNA events arrive. The application then calls the SNA event handler to process events received on this file descriptor and generate any subsequent callbacks. For more information about callbacks, see “The Callback Routine Specified on the nof_async Entry Point”. The application scheduling mode assumes that the application is structured as a main loop consisting of a call to either select or poll followed by code to process event information returned by the select or poll call. To use application scheduling mode, incorporate the following steps into your application code:
Signal-based scheduling mode provides binary compatibility for existing SNAplus2 Release 4 and SNAplus2 Release 5; applications. It is not recommended for new applications because support for signal-based scheduling mode may be discontinued in future versions of SNAplus2. Asynchronous verbs are implemented by making callbacks to the application from signal catcher context. The disadvantages of signal-based scheduling mode are:
To detect work arriving from other components of SNAplus2, the NOF library makes use of the SIGPOLL signal. Applications can require the SIGPOLL signal for other purposes. Therefore, the library daisy-chains to any existing signal catchers. The first verb issued by the application initializes the library's signal catcher. When the SIGPOLL signal arrives, either it indicates work for SNAplus2 or it was generated for some other reason. The NOF library's signal catcher processes the signal and then calls the previous signal catcher to allow the signal to be used for other purposes. The following restrictions apply to SIGPOLL usage:
The HP-UX operating system call sleep can cause problems if applications or their libraries also use signal catchers. Because the SNAplus2 NOF library operates using a signal catcher, do not use the sleep call within a NOF application that uses signal-based scheduling. If necessary, you can use the alarm with a timer to provide the same function. SNAplus2 API libraries are available for linking with multithreaded applications. When you develop applications to operate in a multithreaded environment, the following restrictions apply:
For the HP-UX 10.20 operating system, kernel threads are not supported. New applications will use dynamic libraries in /opt/sna/lib/hpux32 or /opt/sna/lib/hpux64. SNAplus2 release 6.2 also includes a set of dynamic libraries to support existing applications that have been built with previous version of SNAplus2 on PA-Risc. These libraries are on /opt/sna/lib or /opt/sna/lib/pa20_64. There are multiple copies of some libraries to support different levels of the interfaces. Applications that use the Motif interface and whose code consists mainly of callbacks from the Motif libraries are required to add SNA events to the main Xt library scheduling loop. The SNA events allow the SNAplus2 library to run callbacks in order to process asynchronous verb completions. Add the following lines to your code before the first call into any SNA library:
The SNA_USE_XT_SCHED call has no return values. It calls the XtAppAddInput function to register the SNA work sources. When work subsequently arrives on the SNA file descriptor, the Xt library scheduling loop calls the SNA event handler, which then makes any required API callbacks to the application.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||