output.println(" "+
fsen.getSESErecordName()+"* seseToIssue = ("+
fsen.getSESErecordName()+"*) poolalloc( runningSESE->taskRecordMemPool );");
+ output.println(" CHECK_RECORD( seseToIssue );");
} else {
output.println(" "+
fsen.getSESErecordName()+"* seseToIssue = ("+
printf( "mprotect failed, errno=%d.\n", errno );
}
+ printf( "itemSize is 0x%x, allocSize is 0x%x, protectSize is 0x%x.\n", (INTPTR)p->itemSize, (INTPTR)p->allocSize, (INTPTR)p->protectSize );
+ printf( "Intended to protect 0x%x to 0x%x,\n\n", (INTPTR)ptr, (INTPTR)ptr + (INTPTR)(p->protectSize) );
+
exit( -1 );
}
}
// set up the now unneeded record to as the tail of the
// free list by treating its first bytes as next pointer,
MemPoolItem* tailNew = (MemPoolItem*) ptr;
+
tailNew->next = NULL;
while( 1 ) {
// put the memory we intend to expose to client
// on a page-aligned boundary, always return
// new memory
+
INTPTR nonAligned = (INTPTR) RUNMALLOC( p->allocSize );
void* newRec = (void*)((nonAligned + pageSize-1) & ~(pageSize-1));
//printf( "PageSize is %d or 0x%x.\n", (INTPTR)pageSize, (INTPTR)pageSize );
- //printf( "itemSize is 0x%x and allocSize is 0x%x.\n", (INTPTR)p->itemSize, (INTPTR)p->allocSize );
+ //printf( "itemSize is 0x%x, allocSize is 0x%x, protectSize is 0x%x.\n", (INTPTR)p->itemSize, (INTPTR)p->allocSize, (INTPTR)p->protectSize );
//printf( "Allocation returned 0x%x to 0x%x,\n", (INTPTR)nonAligned, (INTPTR)nonAligned + (INTPTR)(p->allocSize) );
//printf( "Intend to use 0x%x to 0x%x,\n\n", (INTPTR)newRec, (INTPTR)newRec + (INTPTR)(p->itemSize) );
topOfRec += p->protectSize - 1;
((char*)topOfRec)[0] = 0x1;
-
-
if( p->initFreshlyAllocated != NULL ) {
p->initFreshlyAllocated( newRec );
}
SESEcommon* c = (SESEcommon*) seseRecord;
pthread_cond_init( &(c->runningChildrenCond), NULL );
pthread_mutex_init( &(c->lock), NULL );
-
- // no need to use return value yet, future maybe
- //return NULL;
+ c->refCount = 0;
+ //c->fresh = 1;
}
#define __MLP_RUNTIME__
+#include <stdlib.h>
+#include <stdio.h>
+
+
#include <pthread.h>
#include "runtime.h"
#include "mem.h"
#include "mlp_lock.h"
#include "memPool.h"
+
+
#ifndef FALSE
#define FALSE 0
#endif
struct REntry_t* rentryArray[NUMRENTRY];
struct REntry_t* unresolvedRentryArray[NUMRENTRY];
-
#ifdef RCR
int offsetToParamRecords;
volatile int rcrstatus;
void rehashMemoryQueue(SESEcommon* seseParent);
+
+
static inline void ADD_REFERENCE_TO( SESEcommon* seseRec ) {
atomic_inc( &(seseRec->refCount) );
}
-static inline void RELEASE_REFERENCE_TO( SESEcommon* seseRec ) {
+static inline int RELEASE_REFERENCE_TO( SESEcommon* seseRec ) {
if( atomic_sub_and_test( 1, &(seseRec->refCount) ) ) {
poolfreeinto( seseRec->parent->taskRecordMemPool, seseRec );
+ return 1;
}
+ return 0;
}
+#define CHECK_RECORD(x) ;
+
+
+////////////////////////////////////////////////
+//
+// Some available debug versions of the above
+// pool allocation-related helpers. The lower
+// 'x' appended to names means they are not hooked
+// up, but check em in so we can switch names and
+// use them for debugging
+//
+////////////////////////////////////////////////
+#define ADD_REFERENCE_TOx(x) atomic_inc( &((x)->refCount) ); printf("0x%x ADD 0x%x on %d\n",(INTPTR)runningSESE,(INTPTR)(x),__LINE__);
+
+#define RELEASE_REFERENCE_TOx(x) if (atomic_sub_and_test(1, &((x)->refCount))) {poolfreeinto(x->parent->taskRecordMemPool, x);printf("0x%x REL 0x%x on %d\n",(INTPTR)runningSESE,(INTPTR)(x),__LINE__);}
+
+#define CHECK_RECORDx(x) { \
+ if( ((SESEcommon*)(x))->refCount != 0 ) { \
+ printf( "Acquired 0x%x from poolalloc, with refCount=%d\n", (INTPTR)(x), ((SESEcommon*)(x))->refCount ); } \
+ if( ((SESEcommon*)(x))->fresh != 1 ) { \
+ printf("0x%x reclaimed 0x%x on %d\n",(INTPTR)runningSESE,(INTPTR)(x),__LINE__); } \
+ ((SESEcommon*)(x))->fresh = 0; \
+}
+
+
// this is for using a memPool to allocate task records,
// pass this into the poolcreate so it will run your