abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
reoUnits.c File Reference
#include "reo.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
reoUnitsAddToFreeUnitList (reo_man *p)
 DECLARATIONS ///. More...
 
reo_unitreoUnitsGetNextUnit (reo_man *p)
 FUNCTION DEFINITIONS ///. More...
 
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

DECLARATIONS ///.

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

]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 162 of file reoUnits.c.

163 {
164  int c;
165  // check that we still have chunks left
166  if ( p->nMemChunks == p->nMemChunksAlloc )
167  {
168  printf( "reoUnitsAddToFreeUnitList(): Memory manager ran out of memory!\n" );
169  fflush( stdout );
170  return;
171  }
172  // allocate the next chunk
173  assert( p->pUnitFreeList == NULL );
175  // split chunks into list-connected units
176  for ( c = 0; c < REO_CHUNK_SIZE-1; c++ )
177  (p->pUnitFreeList + c)->Next = p->pUnitFreeList + c + 1;
178  // set the last pointer to NULL
179  (p->pUnitFreeList + REO_CHUNK_SIZE-1)->Next = NULL;
180  // add the chunk to the array of chunks
181  p->pMemChunks[p->nMemChunks++] = p->pUnitFreeList;
182 }
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nMemChunks
Definition: reo.h:162
reo_unit * pUnitFreeList
Definition: reo.h:160
int nMemChunksAlloc
Definition: reo.h:163
#define REO_CHUNK_SIZE
Definition: reo.h:42
Definition: reo.h:66
reo_unit ** pMemChunks
Definition: reo.h:161
#define assert(ex)
Definition: util_old.h:213
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 135 of file reoUnits.c.

136 {
137  if ( pPlane->pHead == NULL )
138  {
139  pPlane->pHead = pUnit;
140  pUnit->Next = NULL;
141  }
142  else
143  {
144  pUnit->Next = pPlane->pHead;
145  pPlane->pHead = pUnit;
146  }
147  pPlane->statsNodes++;
148 }
reo_unit * Next
Definition: reo.h:76
int statsNodes
Definition: reo.h:83
reo_unit * pHead
Definition: reo.h:90
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 45 of file reoUnits.c.

46 {
47  reo_unit * pUnit;
48  // check there are stil units to extract
49  if ( p->pUnitFreeList == NULL )
51  // extract the next unit from the linked list
52  pUnit = p->pUnitFreeList;
53  p->pUnitFreeList = pUnit->Next;
54  p->nUnitsUsed++;
55  return pUnit;
56 }
static ABC_NAMESPACE_IMPL_START void reoUnitsAddToFreeUnitList(reo_man *p)
DECLARATIONS ///.
Definition: reoUnits.c:162
int nUnitsUsed
Definition: reo.h:164
reo_unit * pUnitFreeList
Definition: reo.h:160
reo_unit * Next
Definition: reo.h:76
Definition: reo.h:66
void reoUnitsRecycleUnit ( reo_man p,
reo_unit pUnit 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 69 of file reoUnits.c.

70 {
71  pUnit->Next = p->pUnitFreeList;
72  p->pUnitFreeList = pUnit;
73  p->nUnitsUsed--;
74 }
int nUnitsUsed
Definition: reo.h:164
reo_unit * pUnitFreeList
Definition: reo.h:160
reo_unit * Next
Definition: reo.h:76
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 87 of file reoUnits.c.

88 {
89  reo_unit * pUnit;
90  reo_unit * pTail = NULL; // Suppress "might be used uninitialized"
91 
92  if ( pPlane->pHead == NULL )
93  return;
94 
95  // find the tail
96  for ( pUnit = pPlane->pHead; pUnit; pUnit = pUnit->Next )
97  pTail = pUnit;
98  pTail->Next = p->pUnitFreeList;
99  p->pUnitFreeList = pPlane->pHead;
100  memset( pPlane, 0, sizeof(reo_plane) );
101 // pPlane->pHead = NULL;
102 }
char * memset()
reo_unit * pUnitFreeList
Definition: reo.h:160
reo_unit * Next
Definition: reo.h:76
Definition: reo.h:80
Definition: reo.h:66
reo_unit * pHead
Definition: reo.h:90
void reoUnitsStopDispenser ( reo_man p)

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

Synopsis [Stops the unit dispenser.]

Description []

SideEffects []

SeeAlso []

Definition at line 115 of file reoUnits.c.

116 {
117  int i;
118  for ( i = 0; i < p->nMemChunks; i++ )
119  ABC_FREE( p->pMemChunks[i] );
120 // printf("\nThe number of chunks used is %d, each of them %d units\n", p->nMemChunks, REO_CHUNK_SIZE );
121  p->nMemChunks = 0;
122 }
int nMemChunks
Definition: reo.h:162
#define ABC_FREE(obj)
Definition: abc_global.h:232
reo_unit ** pMemChunks
Definition: reo.h:161