outtask.println("void * taskptr;");
outtask.println("int numParameters;");
outtask.println("struct parameterdescriptor **descriptorarray;");
+ outtask.println("char * name;");
outtask.println("};");
outtask.println("extern struct taskdescriptor * taskarray[];");
outtask.println("extern numtasks;");
generateTaskDescriptor(outtaskdefs, td);
}
- taskit=state.getTaskSymbolTable().getDescriptorsIterator();
- outtaskdefs.println("struct taskdescriptor * taskarray[]= {");
- boolean first=true;
- while(taskit.hasNext()) {
- TaskDescriptor td=(TaskDescriptor)taskit.next();
- if (first)
- first=false;
- else
- outtaskdefs.println(",");
- outtaskdefs.print("&task_"+td.getSafeSymbol());
+ {
+ //Output task descriptors
+ taskit=state.getTaskSymbolTable().getDescriptorsIterator();
+ outtaskdefs.println("struct taskdescriptor * taskarray[]= {");
+ boolean first=true;
+ while(taskit.hasNext()) {
+ TaskDescriptor td=(TaskDescriptor)taskit.next();
+ if (first)
+ first=false;
+ else
+ outtaskdefs.println(",");
+ outtaskdefs.print("&task_"+td.getSafeSymbol());
+ }
+ outtaskdefs.println("};");
}
- outtaskdefs.println("};");
+
outtaskdefs.println("int numtasks="+state.getTaskSymbolTable().getValueSet().size()+";");
} else if (state.main!=null) {
output.println("struct taskdescriptor task_"+task.getSafeSymbol()+"={");
output.println("&"+task.getSafeSymbol()+",");
output.println("/* number of parameters */" +task.numParameters() + ",");
- output.println("parameterdescriptors_"+task.getSafeSymbol());
+ output.println("parameterdescriptors_"+task.getSafeSymbol()+",");
+ output.println("\""+task.getSymbol()+"\"");
output.println("};");
}
}
}
}
- if (task!=null&&state.TASKDEBUG)
- output.println("printf(\"ENTER "+task.getSymbol()+"\\n\");");
//Do the actual code generation
tovisit=new HashSet();
output.print(" ");
generateFlatNode(fm, current_node, output);
if (current_node.kind()!=FKind.FlatReturnNode) {
- if (task!=null&&state.TASKDEBUG)
- output.println("printf(\"EXIT "+task.getSymbol()+"\\n\");");
output.println(" return;");
}
current_node=null;
private void generateFlatReturnNode(FlatMethod fm, FlatReturnNode frn, PrintWriter output) {
- if (fm.getTask()!=null&&state.TASKDEBUG)
- output.println("printf(\"EXIT "+fm.getTask().getSymbol()+"\\n\");");
if (frn.getReturnTemp()!=null)
output.println("return "+generateTemp(fm, frn.getReturnTemp())+";");
else
/** Boolean flag which indicates whether compiler is compiling a task-based
* program. */
public boolean TASK;
- public boolean TASKDEBUG;
public String structfile;
public String main;
public boolean CONSCHECK=false;
state.CONSCHECK=true;
else if (option.equals("-task"))
state.TASK=true;
- else if (option.equals("-taskdebug"))
- state.TASKDEBUG=true;
else if (option.equals("-help")) {
System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
System.out.println("-dir outputdirectory -- output code in outputdirectory");
struct Queue * activetasks;
struct parameterwrapper * objectqueues[NUMCLASSES];
struct genhashtable * failedtasks;
+extern char ** environ;
+char *options;
+int injectfailures=0;
+float failurechance=0;
+int debugtask=0;
int main(int argc, char **argv) {
GC_init();
#ifdef CONSCHECK
initializemmap();
#endif
+ {
+ int i;
+ options=NULL;
+ for(i=0;environ[i]!=0;i++) {
+ if (strncmp(environ[i],"BRISTLECONE=",12)==0) {
+ options=environ[i]+12;
+ break;
+ }
+ }
+
+ while(options!=NULL) {
+ if (strncmp(options,"-injectfailures",sizeof("-injectfailures")-1)==0) {
+ options=strchr(options,' ');
+ if (options!=NULL) options++;
+ if (options==NULL)
+ break;
+ sscanf(options, "%f", &failurechance);
+ injectfailures=1;
+ printf("Injecting errors with chance=%f\n",failurechance);
+ options=strchr(options,' ');
+ if (options!=NULL) options++;
+ } else if (strncmp(options, "-debugtask",sizeof("-debugtask")-1)==0) {
+ options=strchr(options,' ');
+ if (options!=NULL) options++;
+ debugtask=1;
+ printf("Debug task option on\n");
+ } else
+ break;
+ }
+ }
+
+
{
int i;
/* Allocate startup object */
struct RuntimeHash * forward=allocateRuntimeHash(100);
struct RuntimeHash * reverse=allocateRuntimeHash(100);
void ** checkpoint=makecheckpoint(tpd->task->numParameters, taskpointerarray, forward, reverse);
- if (setjmp(error_handler)) {
+ int x;
+ if (x=setjmp(error_handler)) {
/* Recover */
int h;
#ifdef DEBUG
- printf("Fatal Error! Recovering!\n");
+ printf("Fatal Error=%d, Recovering!\n",x);
#endif
genputtable(failedtasks,tpd,tpd);
restorecheckpoint(tpd->task->numParameters, taskpointerarray, checkpoint, forward, reverse);
} else {
+ if (injectfailures) {
+ if ((((double)random())/RAND_MAX)<failurechance) {
+ printf("\nINJECTING TASK FAILURE to %s\n", tpd->task->name);
+ longjmp(error_handler,10);
+ }
+ }
/* Actually call task */
- ((void (*) (void **)) tpd->task->taskptr)(taskpointerarray);
+ if (debugtask) {
+ printf("ENTER %s\n",tpd->task->name);
+ ((void (*) (void **)) tpd->task->taskptr)(taskpointerarray);
+ printf("EXIT %s\n",tpd->task->name);
+ } else
+ ((void (*) (void **)) tpd->task->taskptr)(taskpointerarray);
}
}
}
+++ /dev/null
-#!/bin/bash
-ROBUSTROOT=~/research/Robust/src
-MAINFILE=$1
-shift
-mkdir tmpbuilddirectory
-java -cp $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary $ROBUSTROOT/ClassLibrary/ -dir tmpbuilddirectory -struct $MAINFILE -task -taskdebug $@
-#gcc -I$ROBUSTROOT/Runtime -Itmpbuilddirectory -O0 -DTASK -g tmpbuilddirectory/methods.c tmpbuilddirectory/taskdefs.c $ROBUSTROOT/Runtime/runtime.c $ROBUSTROOT/Runtime/Queue.c $ROBUSTROOT/Runtime/SimpleHash.c $ROBUSTROOT/Runtime/checkpoint.c $ROBUSTROOT/Runtime/GenericHashtable.c -o $MAINFILE.bin
-gcc -I$ROBUSTROOT/Runtime -I. -IRuntime/include -Itmpbuilddirectory -O0 -DBOEHM_GC -LRuntime/lib/ -lgc -DTASK -DDEBUG -g tmpbuilddirectory/methods.c tmpbuilddirectory/taskdefs.c $ROBUSTROOT/Runtime/runtime.c $ROBUSTROOT/Runtime/file.c $ROBUSTROOT/Runtime/Queue.c $ROBUSTROOT/Runtime/SimpleHash.c $ROBUSTROOT/Runtime/checkpoint.c $ROBUSTROOT/Runtime/GenericHashtable.c -o $MAINFILE.bin
\ No newline at end of file