outmethod.println("#include \"methodheaders.h\"");
outmethod.println("#include \"virtualtable.h\"");
outmethod.println("#include <runtime.h>");
+ if (state.THREAD)
+ outmethod.println("#include <thread.h>");
if (state.main!=null) {
outmethod.println("#include <string.h>");
}
} else {
outmethod.println(" struct ArrayObject * stringarray=allocate_newarray(STRINGARRAYTYPE, argc-1);");
}
+ if (state.THREAD) {
+ outmethod.println("initializethreads();");
+ }
outmethod.println(" for(i=1;i<argc;i++) {");
outmethod.println(" int length=strlen(argv[i]);");
if (GENERATEPRECISEGC) {
outmethod.println(" }");
break;
}
- if (state.THREAD)
- outmethod.println("pthread_exit();");
+ if (state.THREAD) {
+ outmethod.println("pthread_mutex_lock(&threadtable);");
+ outmethod.println("threadcount--;");
+ outmethod.println("pthread_mutex_unlock(&threadtable);");
+ outmethod.println("pthread_mutex_lock(&gclistlock);");
+ outmethod.println("pthread_cond_signal(&gccond);");
+ outmethod.println("pthread_mutex_unlock(&gclistlock);");
+ outmethod.println("pthread_exit(NULL);");
+ }
outmethod.println("}");
}
if (state.TASK)
pthread_mutex_lock(&gclistlock);
pthread_mutex_lock(&threadtable);
if ((listcount+1)==threadcount) {
+ pthread_mutex_unlock(&threadtable);
+ pthread_mutex_unlock(&gclistlock);
break; /* Have all other threads stopped */
}
pthread_mutex_unlock(&threadtable);
struct listitem * tmp=stopforgc((struct garbagelist *)ptr);
pthread_mutex_lock(&gclock);
restartaftergc(tmp);
+ pthread_mutex_unlock(&gclock);
}
}
pthread_mutex_lock(&threadtable);
threadcount--;
pthread_mutex_unlock(&threadtable);
+ pthread_mutex_lock(&gclistlock);
+ pthread_cond_signal(&gccond);
+ pthread_mutex_unlock(&gclistlock);
}
void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {