more changes (get rid of getnewOID and use TRANSREAD macro)
authoradash <adash>
Mon, 6 Apr 2009 18:36:19 +0000 (18:36 +0000)
committeradash <adash>
Mon, 6 Apr 2009 18:36:19 +0000 (18:36 +0000)
Robust/src/Runtime/STM/stm.c
Robust/src/Runtime/STM/tm.h

index 0d3ec4648058237c64d224a198d91082577ac737..75e84dfa07b8de6504905b113155f6f8a6245664 100644 (file)
  */
 
 #include "tm.h"
-
-/* =======================
- * Global variables
- * ======================
- */
-unsigned int oidMin;
-unsigned int oidMax;
-extern int classsize[];
 /* Thread transaction variables */
 __thread objstr_t *t_cache;
 
 
 /* ==================================================
- * dstmStartup
+ * stmStartup
  * This function starts up the transaction runtime. 
  * ==================================================
  */
 int stmStartup() {
-  oidMax = 0xFFFFFFFF;
-  oidMin = 0;
-
   return 0;
 }
 
@@ -83,16 +72,6 @@ objheader_t *transCreateObj(unsigned int size) {
 #endif
 }
 
-//TODO: when reusing oids, make sure they are not already in use!
-static unsigned int id = 0xFFFFFFFF;
-unsigned int getNewOID(void) {
-  id += 2;
-  if (id > oidMax || id < oidMin) {
-    id = (oidMin | 1);
-  }
-  return id;
-}
-
 /* This functions inserts randowm wait delays in the order of msec
  * Mostly used when transaction commits retry*/
 void randomdelay() {
@@ -143,31 +122,15 @@ void *objstrAlloc(objstr_t **osptr, unsigned int size) {
 
 /* =============================================================
  * transRead
- * -finds the objects either in transaction cache or main heap
+ * -finds the objects either in main heap
  * -copies the object into the transaction cache
  * =============================================================
  */
 __attribute__((pure)) objheader_t *transRead(unsigned int oid) {
-  int size;
+  unsigned int machinenumber;
+  objheader_t *tmp, *objheader;
   objheader_t *objcopy;
-  chashlistnode_t *node;
-
-  if(oid == 0) {
-    return NULL;
-  }
-  
-  /* Read from the transaction cache */
-  node= &c_table[(oid & c_mask)>>1];
-  do {
-    if(node->key == oid) {
-#ifdef COMPILER
-    return &((objheader_t*)node->val)[1];
-#else
-    return node->val;
-#endif
-    }
-    node = node->next;
-  } while(node != NULL);
+  int size;
 
   /* Read from the main heap */
   objheader_t *header = (objheader_t *)(((char *)(&oid)) - sizeof(objheader_t)); 
index 485fe35bdf45b9bd3a100d0c1323321f7d0f43dd..60d21cad008edff3ae28edfb8677933dbb73febc 100644 (file)
@@ -38,9 +38,6 @@
 #define NEW   0x02
 #define LOCK  0x04
 
-//TODO Remove later
-#define NUMCLASSES 22
-
 /* ================================
  * Constants
  * ================================
 #define DEFAULT_OBJ_STORE_SIZE 1048510 //1MB
 #define OSUSED(x) (((unsigned int)(x)->top)-((unsigned int) (x+1)))
 #define OSFREE(x) ((x)->size-OSUSED(x))
+#define TRANSREAD(x,y) { \
+  unsigned int inputvalue;\
+if ((inputvalue=(unsigned int)y)==0) x=NULL;\
+else { \
+chashlistnode_t * cnodetmp=&c_table[(inputvalue&c_mask)>>1];   \
+do { \
+  if (cnodetmp->key==inputvalue) {x=(void *)&((objheader_t*)cnodetmp->val)[1];break;} \
+cnodetmp=cnodetmp->next;\
+ if (cnodetmp==NULL) {x=(void *)transRead(inputvalue); asm volatile("":"=m"(c_table),"=m"(c_mask));break;} \
+} while(1);\
+}}
 
 /* =================================
  * Data structures 
@@ -97,6 +105,11 @@ typedef struct objheader {
 }
 
 #else
+#define OID(x) x->oid
+#define TYPE(x) x->type
+#define STATUS(x) x->status
+#define STATUSPTR(x) &x->status
+#define GETSIZE(size, x) size=classsize[TYPE(x)]
 #endif
 
 /* ================================