1: # include   <ingres.h>
   2: # include   <access.h>
   3: # include   <lock.h>
   4: # include   <sccs.h>
   5: 
   6: SCCSID(@(#)cslocks.c	8.1	12/31/84)
   7: 
   8: struct lockreq  Lock;
   9: /*
  10:  *	setcsl- set a critical section lock
  11:  */
  12: setcsl(rtid)
  13: long    rtid;
  14: {
  15:     register char   *r;
  16:     register int    i;
  17:     auto    int ret_val;        /* value returned from the lock driver */
  18: 
  19: #	ifdef xATR1
  20:     if ( tTf(28,0) )
  21:     {
  22:         printf(" setcsl ");
  23:         dumptid(&rtid);
  24:     }
  25: #	endif
  26: 
  27:     if (Alockdes < 0)
  28:         return (1);
  29:     Lock.lract = A_SLP; /* sleep while waiting on lock */
  30:     Lock.lrtype = T_CS; /* critical section lock */
  31:     Lock.lrmod = M_EXCL;    /* exclusive access */
  32:     bmove(&rtid, Lock.lrel, 4); /* copy relid */
  33:     r = Lock.lpage;
  34:     for (i = 0; i < 4; i++)
  35:             /* zero out pageid */
  36:         *r++ = 0;
  37:     i = write(Alockdes, &Lock, KEYSIZE+3);
  38:     read(Alockdes,&ret_val, sizeof (int));
  39:     return (ret_val);
  40: }
  41: 
  42: 
  43: 
  44: /*
  45:  *	unlcs- unlock a critical section
  46:  */
  47: unlcs(rtid)
  48: long    rtid;
  49: {
  50:     register char   *r;
  51:     register int    i;
  52:     auto    int ret_val;
  53: 
  54: #	ifdef xATR1
  55:     if (tTf(28, 1))
  56:     {
  57:         printf(" unlcs ");
  58:         dumptid(rtid);
  59:     }
  60: #	endif
  61: 
  62:     if (Alockdes < 0)
  63:         return (1);
  64:     Lock.lract = A_RLS1;
  65:     Lock.lrtype = T_CS;
  66:     bmove(&rtid, Lock.lrel, 4); /* copy relation identifier */
  67:     r = Lock.lpage;
  68:     for (i = 0; i < 4; i++)
  69:             /* zero out page id */
  70:         *r++ = 0;
  71:     i = write(Alockdes, &Lock, KEYSIZE + 3);
  72:     read(Alockdes,&ret_val, sizeof (int) );
  73:     return (ret_val);
  74: }

Defined functions

setcsl defined in line 12; used 1 times
unlcs defined in line 47; used 2 times

Defined variables

Lock defined in line 8; used 11 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 929
Valid CSS Valid XHTML 1.0 Strict