Annotation of cci/sys/h/iidr.h.2.0, revision 1.1.1.1

1.1       root        1: /*
                      2: **     Copyright (c) 1983 Relational Technology Inc.
                      3: **
                      4: **     IIDR.H  - structures for the INGRES lock driver
                      5: **
                      6: **     Description:
                      7: **             Defines the constants and the structures used by the lock device.
                      8: */
                      9: #ifdef vax
                     10: #undef BYTE_SWAP
                     11: #undef NOTVAX
                     12: #else
                     13: #define        BYTE_SWAP
                     14: #define        NOTVAX
                     15: #endif
                     16: 
                     17: /*     The request codes to the lock device.           */
                     18: 
                     19: # define       KN_R_LOCK       1
                     20: # define       KN_R_UNLOCK     2
                     21: # define       KN_R_CONVERT    3
                     22: # define       KN_R_RELEASE    4
                     23: # define       KN_R_UNIQ       5
                     24: # define       KN_R_STAT       6
                     25: 
                     26: /*     The lock modes that the device supports          */
                     27: 
                     28: # define       KN_M_NL         0
                     29: # define       KN_M_CR         1
                     30: # define       KN_M_CW         2
                     31: # define       KN_M_PR         3
                     32: # define       KN_M_PW         4
                     33: # define       KN_M_EX         5
                     34: 
                     35: /*     Possible extra return values from the lock device       */
                     36: 
                     37: # define       EDEADLOCK       -1
                     38: # define       ECHILDREN       -2
                     39: # define       ELOCKID         -3
                     40: # define       ENOTQUEUED      -4
                     41: # define       ERESOURCE       -5
                     42: # define       EBUG            -6
                     43: 
                     44: /*     The structure used by the user to pass lock key information to the lock device. */
                     45: 
                     46: typedef struct
                     47: {
                     48:        short   lk_parent;                      /*      parentid when setting a lock    */
                     49:        short   lk_type;                        /*      the type of lock                */
                     50:        long    lk_key;                         /*      the key when setting a lock     */
                     51: }      LOCK_KEY;
                     52: 
                     53: /*     Collect performance numbers about the lock device in this structure.    */
                     54: 
                     55: typedef struct
                     56: {
                     57:        long    ii_locks;               /*      number of lock requests                 */
                     58:        long    ii_unlocks;             /*      number of unlocks requests              */
                     59:        long    ii_converts;            /*      number of conversion requests           */
                     60:        long    ii_lockwaits;           /*      number of lock requests that waited     */
                     61:        long    ii_waitconverts;        /*      number of convert requests that waited  */
                     62:        long    ii_deadconverts;        /*      number of conversion deadlocks          */
                     63:        long    ii_deadsearchs;         /*      number of deadlock searches performed   */
                     64:        long    ii_deadlocks;           /*      number of resource deadlocks found      */
                     65: }      STAT;
                     66: 
                     67: /*
                     68:        The format of a request code to the lock device.
                     69: 
                     70:        BYTE_SWAP must be defined for processors such as
                     71:                the 3B5 and 68K where the byte order is
                     72:                the opposite of the vax.
                     73: */
                     74: 
                     75: typedef struct
                     76: {
                     77: #      ifndef  BYTE_SWAP
                     78:        unsigned        cmd_opcode:3;           /* function code        */
                     79:        unsigned        cmd_lock_mode:3;        /* lock mode            */
                     80:        unsigned        cmd_no_queue:1;         /* don't wait modifier  */
                     81: #      else
                     82:        unsigned        cmd_pad:25;             /* count on bit order   */
                     83:        unsigned        cmd_no_queue:1;         /* don't wait modifier  */
                     84:        unsigned        cmd_lock_mode:3;        /* lock mode            */
                     85:        unsigned        cmd_opcode:3;           /* function code        */
                     86: #      endif
                     87: }      CMD;
                     88: 
                     89: typedef struct _QUEUE  QUEUE;
                     90: 
                     91: struct _QUEUE
                     92: {
                     93:        QUEUE   *q_next;
                     94:        QUEUE   *q_prev;
                     95: };
                     96: 
                     97: QUEUE  *remque();
                     98: QUEUE  *insque();
                     99: 
                    100: typedef struct _LKB LKB;
                    101: typedef struct _RSB RSB;
                    102: 
                    103: /*
                    104: **     A Resource Block.
                    105: **             An RSB is allocated for each unique key that is locked.
                    106: **             It contains information about that states of locks queued against this resource.
                    107: */
                    108: 
                    109: struct _RSB
                    110: {
                    111:        QUEUE           rsb_next;                       /*      next of hash chain                                      */
                    112:        QUEUE           rsb_wait_lkb;                   /*      queue of waiting locks                                  */
                    113:        QUEUE           rsb_grant_lkb;                  /*      queue of granted locks followed by conversion requests  */
                    114:        RSB             *rsb_parent;                    /*      parent resource                                         */
                    115:        LKB             *rsb_deadlock_next;             /*      used to save next on recursion in deadlock tree         */
                    116:        LKB             *rsb_deadlock_curr;             /*      used to save curr on recursion in deadlock tree         */
                    117:        int             rsb_pad;                        /*      for future use                                          */
                    118:        union
                    119:        {
                    120:                LOCK_KEY        rsb_lk;                 /*      used to save lock from user     */
                    121:                struct
                    122:                {
                    123:                        unsigned char   rsb_xgrant_mode;        /*      granted mode of locked          */
                    124:                        unsigned char   rsb_xconvert_mode;      /*      effective convert mode          */
                    125:                        short           rsb_xtype;              /*      first part of the key           */
                    126:                        long            rsb_xrkey;              /*      second part of the key          */
                    127:                }               rsb_actual;
                    128:        }               rsb_key;
                    129: };
                    130: 
                    131: # define       rsb_grant_mode          rsb_key.rsb_actual.rsb_xgrant_mode
                    132: # define       rsb_convert_mode        rsb_key.rsb_actual.rsb_xconvert_mode
                    133: # define       rsb_depth               rsb_key.rsb_actual.rsb_xdepth
                    134: # define       rsb_type                rsb_key.rsb_actual.rsb_xtype
                    135: # define       rsb_rkey                rsb_key.rsb_actual.rsb_xrkey
                    136: 
                    137: /*
                    138: **     The User structure.
                    139: **             Contains information about processes that currently have the lock device open.
                    140: **             Used to store information that can't be put in the 'u' struct.
                    141: */
                    142: 
                    143: typedef struct
                    144: {
                    145:        short           usr_pid;                        /*      something to identify this process      */
                    146:        char            usr_state;                      /*      miscellaneous status info               */
                    147:        char            usr_visited;                    /*      noded visited marke for deadlock search */
                    148:        LKB             *usr_wait;                      /*      lock that we are waiting on             */
                    149: }      USR;
                    150: 
                    151: # define       USR_NULLSTATE   00
                    152: # define       USR_WAIT        01
                    153: # define       USR_VISITED     01
                    154: # define       USR_NOTVISITED  00
                    155: 
                    156: /*
                    157: **     The Lock Block.
                    158: **             Contains information about a given processes lock request against a resource.
                    159: */
                    160: 
                    161: struct _LKB
                    162: {
                    163:        QUEUE           lkb_next;                       /*      next LBK of the same type       */
                    164:        LKB             *lkb_parent;                    /*      parent lock block               */
                    165:        RSB             *lkb_rsb;                       /*      associated resource block       */
                    166:        USR             *lkb_usr;                       /*      owning process                  */
                    167:        unsigned char   lkb_grant_mode;                 /*      granted mode                    */
                    168:        unsigned char   lkb_request_mode;               /*      requested lock mode             */
                    169:        unsigned char   lkb_state;                      /*      current lock state              */
                    170:        unsigned char   lkb_children;                   /*      number of child locks           */
                    171: };
                    172: 
                    173: # define       LKB_FREE        0
                    174: # define       LKB_GRANT       1
                    175: # define       LKB_CONVERT     2
                    176: # define       LKB_WAIT        3

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.