| OpenSS7 SS7 for the Common Man | © Copyright 1997-2007 OpenSS7 Corporation All Rights Reserved. Last modified: Sat, 01 Nov 2008 10:41:53 GMT | ||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
| Manpage of APPQDescription: Manual PageKeywords: ss7 ss7/ip ss7 over ip ss7 mtp ss7 sccp ss7 tcap sigtran mtp sccp tcap openss7 acb56 linux telephony pstn linux telephony linux nebs linux compactpciAPPQSection: Linux Fast-STREAMS DDI/DKI (9)Updated: 2008-10-31 Index Return to Main Contents NAMEappq - append one STREAMS message after anotherSYNOPSIS#define _LIS_SOURCE
ARGUMENTS
INTERFACESTREAMS, implementation extension. DESCRIPTIONappq() appends the STREAMS message nmp just after the message emp already on queue q. If there is no message after emp in the queue q, or emp is NULL, this has the same effect as calling putq(9) with q and nmp. appq() performs all of the normal STREAMS scheduler functions associated with putq(9) including enabling of the queue, q, when the first message or a high priority message is placed on the queue. If queue scheduling has been disabled with noenable(9), only high priority messages will result in the queue being scheduled. Message Queueing PrioritySTREAMS queues messages based on message queueing priority. There are three priority classes for messages that can be tested with pcmsg(9):
appq() only examines the message class and priority band of the first message block of a message. If a high priority message is passed to appq() with a non-zero b_band value, b_band is reset to zero (0) before placing the message on the queue. If a normal priority message is passed to appq() with b_band value greater than the number of qband(9) structures associated with the queue, appq() attempts to allocate a new qband(9) structure for each band up to and including the band of the message. (But, see COMPATIBILTY , below.) Messages must be placed in order in the queue. If the message is a high priority message, it must be placed on the queue with other high priority messages and ahead of normal priority and ordinary messages. If the message is a normal priority message with a non-zero b_band, it must be placed with other messages in the queue band. If the message is a ordinary message (with a zero b_band), it must be placed with other ordinary messages, after all other messages. Attempts to insert a message out of order in the queue with appq() will cause appq() to fail. Placing the first message for a queue band onto the queue can result in the allocation of a qband(9) structure to provide flow control accounting for the queue band. Failure to allocate a qband(9) structure can cause appq() to fail. Failure can be avoided by ensuring that a qband(9) structure exists for the band, b_band, using strqget(9) or strqset(9). Whether a qband(9) exists for a given b_band can be determined by examining the q_nband member of the queue(9) structure. When q_nband>=b_band, a structure exists; when q_nband<b_band, one needs to be allocated. Flow ControlIf a high priority message is placed onto the queue, the queue will always be enabled, as with qenable(9); that is, the queue's qi_srvp(9) procedure will be scheduled if it exists (and is not already scheduled). This is true for appq(), insq(9), putq(9), and putbq(9). Because this is true, a high priority message should never be placed back on a queue by the queue's qi_srvp(9) procedure with putbq(9), otherwise and indefinite loop could result. appq() is allowed to enable the queue (QNOENB is not set) if the message is a normal priority message, or the QWANTR flag is set indicating that the qi_srvp(9) procedure is ready to read the queue. If a normal priority message with a non-zero b_band is placed onto an empty queue band, the queue will be enabled, as with enableq(9); that is, the queue's qi_srvp(9) procedure will be scheduled if it exists (and is not already scheduled) and the QNOENB flag has not been set for the queue with noenable(9). If a ordinary message with a zero b_band is placed onto an empty queue and the QWANTR flag is set for the queue, then the queue will be enabled, as with enableq(9); that is, the queue's qi_srvp(9) procedure will be scheduled if it exists (and is not already scheduled) and the QNOENB flag has not been set for the queue with noenable(9). Another way of putting this is that appq() will enable the queue if the queue is not inhibited with noenable(9) and one of the following conditions also holds true:
When an ordinary message is enqueued by appq(), it will cause the qi_srvp(9) procedure to be scheduled only if the queue was previously empty, and a previous getq(9) call returns NULL (that is, the QWANTR flag is set). If there are messages on the queue, appq() presumes that the qi_srvp(9) procedure is blocked by flow control and the procedure will be rescheduled by STREAMS when the block is removed. As a general rule for appq(), insq(9), putq(9), and putbq(9), the queue is enabled whenever the message placed on the message queue becomes the first message on the queue, unless the message is a normal priority message and the queue has been disabled with noenable(9), or the message was placed with putbq(9). USAGEappq() is an LiS-specific function that should not be called by portable STREAMS drivers and modules. Instead, the driver or modules should use the DDI/DKI defined insq(9). RETURNUpon success, appq() returns true (1) and the message pointed to by mp has been appended into the queue. Upon failure, appq() returns false (0) and the message pointed to by mp remains unaltered. ERRORSappq() fails silently if nmp is associated with a non-existent queue band and a queue band structure could not be allocated. This error can be avoided by assuring that a queue band structure exists with strqset(9) before the call to appq() is made with a banded nmp. CONTEXTappq() can be called from any context, including process context, module procedures, callouts, callbacks, soft interrupts, and interrupt service routines. MP-STREAMSappq() is MP-safe; however, the caller is responsible for the validity of the passed in queue and message pointers, and exclusive access to the passed in messages. Validity of qThe caller is responsible for the validity of the passed in queue pointer, q. q is valid from all procedures synchronous on q, including qi_qopen(9), qi_qclose(9), qi_putp(9), qi_srvp(9), procedures and synchronous callback functions. For process context, asynchronous callback functions, soft interrupts (tasklets and bottom halves), and interrupt service routines, that is, when calling appq() from a non-STREAMS context, any valid queue pointer, q, can be passed to appq(); however, the caller must ensure that the queue pointer remains valid across the call. In general, q is valid from the moment that qprocson(9) returns until the moment that qprocsoff(9) is called, so, if the non-STREAMS code sections are passed a pointer from q's qi_qopen(9) procedure and invalidated by its qi_qclose() procedure, validity can be ensured. (This is the case with timeout(9) and bufcall(9) asynchronous callbacks. These callbacks are passed a queue pointer only after qi_qopen(9) and must be cancelled before qi_qclose(9) returns.) Otherwise, from outside of STREAMS context, it is still possible to derive a queue pointer from a validated queue pointer, provided that the Stream is frozen with a call to freezestr(9). Under Linux Fast-STREAMS[1], it is permissible to call appq() on a Stream that is frozen with freezestr(9), and freezestr(9) can be called from any context. appq() takes a recursive freeze lock that can be acquired by the caller when the Stream is frozen. If another thread has the Stream frozen with freezestr(9), the calling processor will spin until the Stream is thawed by the other thread with unfreezestr(9). Validity and Exclusion for empEnsuring validity and exclusion for emp is difficult on SMP systems, because concurrent calls to appq(9), insq(9), putq(9), putbq(9), can change emp->b_next and rmvq(9), getq(9), flushq(9), flushband(9), can change emp->b_prev and invalidate a previous emp pointer dereference (e.g., by removing the message from the queue and freeing it). Validity and exclusion for emp on both UP and SMP systems can be readily ensured by freezing the queue, q, using freezestr(9) before referencing emp, and across the call to appq(). However, it is also possible to ensure validity and exclusion with qwriter(9), streams_put(9), with appropriate synchronization boundaries (STR_PERQUEUE or D_MTPERQ), or with module private locks. Because freezing the Stream is not the only way to provide the necessary assurances, Linux Fast-STREAMS[1] does not require that the Stream be frozen by the caller, although it is recommended. Similar synchronization is necessary for the use of appq(), insq(9), and rmvq(9). appq() protects its dereferencing of the emp->b_next pointer with the queue write lock, making it safe to be called concurrent with putq(9), putbq(9), insq(9), getq(9), flushq(9), flushband(9), rmvq(9) or a concurrent call to appq(). Validity and Exclusion for nmpValidity of the nmp pointer and exclusive access to the message pointed to by nmp is normally assured in the usual ways: If nmp was just allocated using allocb(9) or esballoc(9), or, if nmp was just removed from a message queue with getq(9) or rmvq(9), then exclusion and validity is assured. IMPLEMENTATIONappq() is implemented under Linux Fast-STREAMS using insq(9). Essentially, appq(q,emp,nmp) is the same as insq(q,emp?emp->b_next,nmp) except that the emp dereference is protected by the queue write lock. NOTICESappq() is a LiS-specific function: _LIS_SOURCE must be defined before including DDI/DKI include files to expose this symbol. Linux Fast-STREAMS must also have been compiled with CONFIG_STREAMS_COMPAT_LIS or CONFIG_STREAMS_COMPAT_LIS_MODULE defined. appq() called with an existing message pointer, emp, argument that is not on the queue, q, will panic or destabilize the kernel. EXAMPLESSEE ALSOflushband(9), flushq(9), freezestr(9), getq(9), insq(9), noenable(9), putbq(9), putq(9), putq(9), qwriter(9), rmvq(9), streams_put(9), strqset(9). BUGSCOMPATIBILITYappq() is compatible with LiS with the following portability considerations:
See STREAMS(9) for additional compatibility information. CONFORMANCELfS[1] and LiS[3] source code. HISTORYappq() first appeared in LiS. Before OpenSS7 release LIS-2.16.18-17, appq() returned void. As of OpenSS7 release LIS-2.16.18-17, appq() returns int. REFERENCES
TRADEMARKS
Other trademarks are the property of their respective owners. IDENTIFICATION
Copyright©1997-2008OpenSS7 Corp.
All Rights Reserved.
Index
This document was created by man2html, using the manual pages. Time: 05:12:05 GMT, June 18, 2013 | ||||||||||||||||||||||||||||||||||
| OpenSS7 SS7 for the Common Man |
| ||||||||||||||||||||||||||||||||||
| Last modified: Sat, 01 Nov 2008 10:41:53 GMT © Copyright 1997-2007 OpenSS7 Corporation All Rights Reserved. | |||||||||||||||||||||||||||||||||||