Data structures


Streams are often described as linked lists of data structures. Since all message passing is done the same way, regardless of what a module might do to the data internally, we can ignore the modules themselves for the moment and view individual Streams as a set of queues with related structures hanging off the sides.

Queues are always allocated in pairs: one for the upstream side and one for downstream. The structures for each side are as follows :

  • queue structure ” Keeps track of the data. This contains pointers to a qband and a qinit structure.

  • qband structure ” Identifies priority bands (also called out-of- band data)

  • qinit structure ” Identifies the processing procedures for the module. This points to module_infr and module_stat structures.

  • module_info structure ” Holds initial values and setup.

  • module_stat structure ” Contains statistics.

The queue structure also has:

  • a pointer to the first message on the queue, if any

  • a pointer to the last message on the queue

Each queue structure contains a pointer to the next queue in the chain and can identify its paired queue (same module, going in the opposite direction) with a macro.

Here is an illustration of the data structures.

Figure 25-2. Queue data structures

graphics/25fig02.gif

When looking at a running kernel or a crash, identifying and locating active streams is slightly different from SunOS 4.x to Solaris 2.

  • In SunOS 4.x, the kernel variable allstream points to a linked list of active stdata structures, each of which identifies a stream head.

  • In Solaris 2, stdata structures no longer contain links. An encompassing structure ( shinfo , for stream head info ) contains the stdata structure plus a couple of links, forward and back. A pointer to the start of a linked list of shinfo structures is contained as the first element of the global Strinfo array.

    The header file strsubr.h in /usr/include/sys includes a definition of the strinfo structure. The Strinfo array contains these structures. The first element is the one of interest, but the others may be relevant if you're searching through Streams. The second, for example, is a list of all the queue structures.

    Example 25-1 String info structure as defined in /usr/include/sys/strsubr.h on Solaris 2
     /*  * Structure to keep track of resources that have been allocated  * for streams - an array of these are kept, one entry per  * resource. This is used by crash to dump the data structures.  */  struct strinfo {     void   *sd_head;  /* head of in-use list */      int    sd_cnt;    /* total # allocated */  };  #define DYN_STREAM 0  /* for stream heads */ 
  • Individual vnodes also contain a pointer to the stdata struct in use by that Stream.



PANIC. UNIX System Crash Dump Analysis Handbook
PANIC! UNIX System Crash Dump Analysis Handbook (Bk/CD-ROM)
ISBN: 0131493868
EAN: 2147483647
Year: 1994
Pages: 289
Authors: Chris Drake

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net