src/bdd/reo/reoUnits.c File Reference

#include "reo.h"
Include dependency graph for reoUnits.c:

Go to the source code of this file.

Functions

static void reoUnitsAddToFreeUnitList (reo_man *p)
reo_unitreoUnitsGetNextUnit (reo_man *p)
void reoUnitsRecycleUnit (reo_man *p, reo_unit *pUnit)
void reoUnitsRecycleUnitList (reo_man *p, reo_plane *pPlane)
void reoUnitsStopDispenser (reo_man *p)
void reoUnitsAddUnitToPlane (reo_plane *pPlane, reo_unit *pUnit)

Function Documentation

void reoUnitsAddToFreeUnitList ( reo_man p  )  [static]

CFile****************************************************************

FileName [reoUnits.c]

PackageName [REO: A specialized DD reordering engine.]

Synopsis [Procedures which support internal data structures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - October 15, 2002.]

Revision [

Id
reoUnits.c,v 1.0 2002/15/10 03:00:00 alanmi Exp

] DECLARATIONS ///

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 158 of file reoUnits.c.

00159 {
00160         int c;
00161         // check that we still have chunks left
00162         if ( p->nMemChunks == p->nMemChunksAlloc )
00163         {
00164                 printf( "reoUnitsAddToFreeUnitList(): Memory manager ran out of memory!\n" );
00165                 fflush( stdout );
00166                 return;
00167         }
00168         // allocate the next chunk
00169         assert( p->pUnitFreeList == NULL );
00170         p->pUnitFreeList = ALLOC( reo_unit, REO_CHUNK_SIZE );
00171         // split chunks into list-connected units
00172         for ( c = 0; c < REO_CHUNK_SIZE-1; c++ )
00173                 (p->pUnitFreeList + c)->Next = p->pUnitFreeList + c + 1;
00174         // set the last pointer to NULL
00175         (p->pUnitFreeList + REO_CHUNK_SIZE-1)->Next = NULL;
00176         // add the chunk to the array of chunks
00177         p->pMemChunks[p->nMemChunks++] = p->pUnitFreeList;
00178 }

void reoUnitsAddUnitToPlane ( reo_plane pPlane,
reo_unit pUnit 
)

Function*************************************************************

Synopsis [Adds one unit to the list of units which constitutes the plane.]

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file reoUnits.c.

00132 {
00133         if ( pPlane->pHead == NULL )
00134         {
00135                 pPlane->pHead = pUnit;
00136                 pUnit->Next   = NULL;
00137         }
00138         else
00139         {
00140                 pUnit->Next   = pPlane->pHead;
00141                 pPlane->pHead = pUnit;
00142         }
00143         pPlane->statsNodes++;
00144 }

reo_unit* reoUnitsGetNextUnit ( reo_man p  ) 

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Extract the next unit from the free unit list.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file reoUnits.c.

00043 {
00044         reo_unit * pUnit;
00045         // check there are stil units to extract
00046         if ( p->pUnitFreeList == NULL )
00047                 reoUnitsAddToFreeUnitList( p );
00048         // extract the next unit from the linked list
00049         pUnit            = p->pUnitFreeList;
00050         p->pUnitFreeList = pUnit->Next;
00051         p->nUnitsUsed++;
00052         return pUnit;
00053 }

void reoUnitsRecycleUnit ( reo_man p,
reo_unit pUnit 
)

Function*************************************************************

Synopsis [Returns the unit to the free unit list.]

Description []

SideEffects []

SeeAlso []

Definition at line 66 of file reoUnits.c.

00067 {
00068         pUnit->Next      = p->pUnitFreeList;
00069         p->pUnitFreeList = pUnit;
00070         p->nUnitsUsed--;
00071 }

void reoUnitsRecycleUnitList ( reo_man p,
reo_plane pPlane 
)

Function*************************************************************

Synopsis [Returns the list of units to the free unit list.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file reoUnits.c.

00085 {
00086         reo_unit * pUnit;
00087         reo_unit * pTail;
00088 
00089         if ( pPlane->pHead == NULL )
00090                 return;
00091 
00092         // find the tail
00093         for ( pUnit = pPlane->pHead; pUnit; pUnit = pUnit->Next )
00094                 pTail = pUnit;
00095         pTail->Next = p->pUnitFreeList;
00096         p->pUnitFreeList    = pPlane->pHead;
00097         memset( pPlane, 0, sizeof(reo_plane) );
00098 }

void reoUnitsStopDispenser ( reo_man p  ) 

Function*************************************************************

Synopsis [Stops the unit dispenser.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file reoUnits.c.

00112 {
00113         int i;
00114         for ( i = 0; i < p->nMemChunks; i++ )
00115                 free( p->pMemChunks[i] );
00116 //      printf("\nThe number of chunks used is %d, each of them %d units\n", p->nMemChunks, REO_CHUNK_SIZE );
00117         p->nMemChunks = 0;
00118 }


Generated on Tue Jan 5 12:19:01 2010 for abc70930 by  doxygen 1.6.1