From: bdemsky Date: Fri, 9 Oct 2009 07:07:58 +0000 (+0000) Subject: add sandbox files X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0cbafff8ca631dd5a3b908961abd1428a162fc16;p=IRC.git add sandbox files --- diff --git a/Robust/src/Runtime/STM/sandbox.c b/Robust/src/Runtime/STM/sandbox.c new file mode 100644 index 00000000..bf7504f7 --- /dev/null +++ b/Robust/src/Runtime/STM/sandbox.c @@ -0,0 +1,45 @@ +#include "sandbox.h" + +__thread int transaction_check_counter; +__thread jmp_buf aborttrans; +__thread int abortenabled; +__thread int * counter_reset_pointer; + +void checkObjects() { + if (abortenabled&&checktrans()) { + transaction_check_counter=(*counter_reset_pointer=HIGH_CHECK_FREQUENCY); + longjmp(aborttrans, 1); + } + transaction_check_counter=*counter_reset_pointer; +} + +/* Do sandboxing */ +void errorhandler(int sig, struct sigcontext ctx) { + printf("Error\n"); + if (abortenabled&&checktrans()) + longjmp(aborttrans, 1); + threadhandler(sig, ctx); +} + +int checktrans() { + /* Create info to keep track of objects that can be locked */ + chashlistnode_t *curr = c_list; + + /* Inner loop to traverse the linked list of the cache lookupTable */ + while(likely(curr != NULL)) { + //if the first bin in hash table is empty + objheader_t * headeraddr=&((objheader_t *) curr->val)[-1]; + objheader_t *header=(objheader_t *)(((char *)curr->key)-sizeof(objheader_t)); + unsigned int version = headeraddr->version; + + if (header->lock==0) { + return 1; + } + CFENCE; + if (version!=header->version) { + return 1; + } + curr = curr->lnext; + } + return 0; +} diff --git a/Robust/src/Runtime/STM/sandbox.h b/Robust/src/Runtime/STM/sandbox.h new file mode 100644 index 00000000..a93321df --- /dev/null +++ b/Robust/src/Runtime/STM/sandbox.h @@ -0,0 +1,18 @@ +#ifndef SANDBOX_H +#define SANDBOX_H + +#include +#include +extern __thread jmp_buf aborttrans; +extern __thread int abortenabled; +extern __thread int* counter_reset_pointer; +extern __thread int transaction_check_counter; +void checkObjects(); +#define LOW_CHECK_FREQUENCY 1000000 +#define HIGH_CHECK_FREQUENCY 100000 +int checktrans(); +void errorhandler(int sig, struct sigcontext ctx); + +#endif + +