*/
#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;
}
#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() {
/* =============================================================
* 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));
#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
}
#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
/* ================================