コード例 #1
0
ファイル: ringtest-thread.c プロジェクト: coda/thread-proc
static void treeroutine(const void *const arg)
{
	const ringargument *const ra = (const ringargument *)arg;
	ringlink rl;
	rlform(&rl, ra->readend, ra->writeend);

	if(ra->id)
	{
		rlwrite(&rl, rlread(&rl) + 1);
	}
	else
	{
		rlwrite(&rl, 1);
		printf("got at root %u\n", rlread(&rl));
	}
}
コード例 #2
0
/* PROGRAM: rlmemwt - write the transaction table and phy. backout flag
 *		      into an rlnote
 *
 * RETURNS: DSMVOID
 */
DSMVOID
rlmemwt(dsmContext_t *pcontext)
{
    dbcontext_t *pdbcontext = pcontext->pdbcontext;
    dbshm_t     *pdbpub = pdbcontext->pdbpub;
    MEMNOTE      note;
    TEXT        *ptx;
    TX          *ptrn;
    TEXT        *pdata;
    COUNT        dlen;
    TRANTAB     *ptran = pdbcontext->ptrantab;
    int          i,j,numToGo;
	
TRACE_CB(pcontext, "rlmemwt")

    INITNOTE(note, RL_INMEM, RL_PHY );

    note.rlpbkout = pdbcontext->prlctl->rlpbkout;
    note.lasttask = pdbcontext->pmstrblk->mb_lasttask;
    note.numLive  = pdbcontext->ptrantab->numlive;
    note.numMemnotes = (note.numLive / (UCOUNT)MAX_ENTRIES_PER_NOTE) + 1; 
    note.tmsize = sizeof (TX) - sizeof(txPlus_t);

    /* This is a funny note.  It describes physical state but since no action
    is taken and no database blocks depend on it so we'll write it with... */

    note.rlnote.rlArea   = 0;	/* bug 20000114-034 by dmeyer in v9.1b */
    note.rlnote.rldbk	 = 0;
    note.rlnote.rlupdctr = 0;
    
    note.spare[0] = 0;
    note.spare[1] = 0;
    
    /* put 0 in the trn id part of the note */
    note.rlnote.rlTrid = 0;

    if ( ptran->numlive > MAX_ENTRIES_PER_NOTE )
        note.numThisNote = MAX_ENTRIES_PER_NOTE;
    else
        note.numThisNote = ptran->numlive;
	
    dlen = note.numThisNote * note.tmsize;
    /* bug 93-01-21-035: use stRent instead of stkpush */

    pdata = (TEXT *)stRentd (pcontext, pdsmStoragePool, (unsigned)dlen);
    
    numToGo = ptran->numlive;
    ptrn = ptran->trn;
    for ( j = 0; j < (int)note.numMemnotes; j++)
    {
       note.noteSequence = j + 1;

       MT_LOCK_AIB();
       note.aiupdctr = pdbcontext->pmstrblk->mb_aictr;
       note.ainew    = pdbcontext->pmstrblk->mb_ai.ainew;

       if(pdbcontext->ptlctl)
       {
           note.tlWriteBlockNumber = pdbcontext->ptlctl->writeLocation;
           note.tlWriteOffset = pdbcontext->ptlctl->writeOffset;

       }
       else
       {
           note.tlWriteBlockNumber = 0;
           note.tlWriteOffset = 0;
       }
       
       if (pdbpub->qaictl)
           note.aiwrtloc =
               pdbcontext->paictl->ailoc + pdbcontext->paictl->aiofst;

       else note.aiwrtloc = 0; /* bug 20000114-034 by dmeyer in v9.1b */

       MT_UNLK_AIB();
       
       for(i=note.numThisNote, ptx = pdata;
	i > 0; ptrn++)
       {
          /* Only copy the transaction if it is in an active state */
	  if (ptrn->txstate && (ptrn->txstate != TM_TS_ALLOCATED) )
	  {
	     bufcop (ptx, (TEXT *)ptrn, note.tmsize);
	     ptx += note.tmsize;
	     i--;
	  }
       }

       /* Why not just use rlputnote here? */
       rlwrite(pcontext, (RLNOTE *)&note, dlen, pdata);
       if (rlainote (pcontext, (RLNOTE *)&note))
       {
	  /* write note to ai also. Notice that the ai information which is
	     recorded in the note will change when we do this. */
	  
	  MT_LOCK_AIB ();
	  
	  rlaiwrt (pcontext, (RLNOTE *)&note, dlen, pdata,
                   ++pdbcontext->pmstrblk->mb_aictr,
		   pcontext->pusrctl->uc_lstdpend);
	  
	  MT_UNLK_AIB ();
       }
       numToGo -= note.numThisNote;
       if( numToGo > MAX_ENTRIES_PER_NOTE )
	  note.numThisNote = MAX_ENTRIES_PER_NOTE;
       else
       {
	  note.numThisNote = numToGo;
	  dlen = numToGo * note.tmsize;
       }
       
    }
    /* bug 93-01-21-035: use stVacate instead of stkpop */
    stVacate (pcontext, pdsmStoragePool, pdata);
    
    /* Write out the ready to commit tx table if there any */
    if( pdbcontext->ptrcmtab != NULL )
	rlrctwt(pcontext);
	
}  /* end rlmemwt */