#define ROW 100 /* columns in the map */
#define COLUMN 100 /* rows of in the map */
-#define ROUNDS 256 /* Number of moves by each player */
+#define ROUNDS 2560 /* Number of moves by each player */
#define PLAYERS 20 /* Number of Players when num Players != num of client machines */
#define RATI0 0.5 /* Number of lumberjacks to number of planters */
#define BLOCK 3 /* Area around the gamer to consider */
t = time(NULL);
req.tv_sec = 0;
- req.tv_nsec = (long)(t%100); //1-11 microsec
+ req.tv_nsec = (long)(t%4); //1-11 microsec
nanosleep(&req, NULL);
return;
}
return oid;
/* Read from the main heap */
+ //No lock for now
objheader_t *header = (objheader_t *)(((char *)oid) - sizeof(objheader_t));
- if(read_trylock(&header->lock)) { //Can further acquire read locks
- GETSIZE(size, header);
- size += sizeof(objheader_t);
- objcopy = (objheader_t *) objstrAlloc(&t_cache, size);
- memcpy(objcopy, header, size);
- /* Insert into cache's lookup table */
- STATUS(objcopy)=0;
- t_chashInsert((unsigned int)oid, &objcopy[1]);
- read_unlock(&header->lock);
- return &objcopy[1];
- }
+ GETSIZE(size, header);
+ size += sizeof(objheader_t);
+ objcopy = (objheader_t *) objstrAlloc(&t_cache, size);
+ memcpy(objcopy, header, size);
+ /* Insert into cache's lookup table */
+ STATUS(objcopy)=0;
+ t_chashInsert((unsigned int)oid, &objcopy[1]);
+ return &objcopy[1];
}
void freenewobjs() {
}
#endif
+#ifdef STM
+__thread char * memorybase=NULL;
+__thread char * memorytop=NULL;
+#endif
+
void collect(struct garbagelist * stackptr) {
#if defined(THREADS)||defined(DSTM)||defined(STM)
if (c_table!=NULL) {
fixtable(&c_table, c_size);
fixobjlist(newobjs);
+ memorybase=NULL;
}
#endif
if ((*listptr->tc_table)!=NULL) {
fixtable(listptr->tc_table, listptr->tc_size);
fixobjlist(listptr->objlist);
+ (*listptr->base)=NULL;
}
#endif
stackptr=listptr->stackptr;
}
#endif
-
struct listitem * stopforgc(struct garbagelist * ptr) {
struct listitem * litem=malloc(sizeof(struct listitem));
litem->stackptr=ptr;
litem->tc_size=c_size;
litem->tc_table=&c_table;
litem->objlist=newobjs;
+ litem->base=&memorybase;
#endif
litem->prev=NULL;
pthread_mutex_lock(&gclistlock);
}
#endif
+#ifdef STM
+#define MEMORYBLOCK 65536
+void * helper(struct garbagelist *, int);
void * mygcmalloc(struct garbagelist * stackptr, int size) {
+ if ((size&7)!=0)
+ size=(size&~7)+8;
+ if (memorybase==NULL||(memorybase+size)>memorytop) {
+ int toallocate=(size>MEMORYBLOCK)?size:MEMORYBLOCK;
+ memorybase=helper(stackptr, toallocate);
+ memorytop=memorybase+toallocate;
+ }
+ char *retvalue=memorybase;
+ memorybase+=size;
+ return retvalue;
+}
+
+void * helper(struct garbagelist * stackptr, int size) {
+#else
+void * mygcmalloc(struct garbagelist * stackptr, int size) {
+#endif
void *ptr;
#if defined(THREADS)||defined(DSTM)||defined(STM)
if (pthread_mutex_trylock(&gclock)!=0) {