12 pthread_mutex_t gclock;
13 pthread_mutex_t gclistlock;
14 pthread_cond_t gccond;
15 pthread_mutex_t objlock;
16 pthread_cond_t objcond;
17 pthread_key_t threadlocks;
21 struct ___Object___ *ll=pthread_getspecific(threadlocks);
23 struct ___Object___ *llnext=ll->___nextlockobject___;
24 ll->___nextlockobject___=NULL;
25 ll->___prevlockobject___=NULL;
27 ll->tid=0; //unlock it
30 pthread_mutex_lock(&objlock);//wake everyone up
31 pthread_cond_broadcast(&objcond);
32 pthread_mutex_unlock(&objlock);
34 pthread_mutex_lock(&gclistlock);
36 pthread_cond_signal(&gccond);
37 pthread_mutex_unlock(&gclistlock);
41 void threadhandler(int sig, siginfo_t *info, void *uap) {
43 printf("sig=%d\n",sig);
49 void initializethreads() {
52 pthread_mutex_init(&gclock, NULL);
53 pthread_mutex_init(&gclistlock, NULL);
54 pthread_cond_init(&gccond, NULL);
55 pthread_mutex_init(&objlock,NULL);
56 pthread_cond_init(&objcond,NULL);
57 pthread_key_create(&threadlocks, NULL);
59 initializeexithandler();
61 sig.sa_sigaction=&threadhandler;
62 sig.sa_flags=SA_SIGINFO;
63 sigemptyset(&sig.sa_mask);
65 /* Catch bus errors, segmentation faults, and floating point exceptions*/
66 sigaction(SIGBUS,&sig,0);
67 sigaction(SIGSEGV,&sig,0);
68 sigaction(SIGFPE,&sig,0);
69 signal(SIGPIPE, SIG_IGN);
73 void initthread(struct ___Thread___ * ___this___) {
75 struct ___Thread______staticStart____L___Thread____params p={1, NULL, ___this___};
76 ___Thread______staticStart____L___Thread___(&p);
78 ___Thread______staticStart____L___Thread___(___this___);
80 pthread_mutex_lock(&gclistlock);
82 pthread_cond_signal(&gccond);
83 pthread_mutex_unlock(&gclistlock);
87 void CALL11(___Thread______sleep____J, long long ___millis___, long long ___millis___) {
90 struct listitem *tmp=stopforgc((struct garbagelist *)___params___);
102 void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {
105 pthread_attr_t nattr;
107 pthread_mutex_lock(&gclistlock);
109 pthread_mutex_unlock(&gclistlock);
110 pthread_attr_init(&nattr);
111 pthread_attr_setdetachstate(&nattr, PTHREAD_CREATE_DETACHED);
114 retval=pthread_create(&thread, &nattr, (void * (*)(void *)) &initthread, VAR(___this___));
119 pthread_attr_destroy(&nattr);
124 void CALL12(___Thread______start____I, int ___mid___, struct ___Thread___ * ___this___, int ___mid___) {
125 startRemoteThread((unsigned int)VAR(___this___), ___mid___);
130 void initDSMthread(int *ptr) {
135 int p[]={1, 0 /* NULL */, oid};
136 ((void (*)(void *))virtualtable[type*MAXCOUNT+RUNMETHOD])(p);
138 ((void (*)(void *))virtualtable[type*MAXCOUNT+RUNMETHOD])(oid);
140 pthread_mutex_lock(&gclistlock);
142 pthread_cond_signal(&gccond);
143 pthread_mutex_unlock(&gclistlock);
146 void startDSMthread(int oid, int objType) {
149 pthread_attr_t nattr;
151 pthread_mutex_lock(&gclistlock);
153 pthread_mutex_unlock(&gclistlock);
154 pthread_attr_init(&nattr);
155 pthread_attr_setdetachstate(&nattr, PTHREAD_CREATE_DETACHED);
156 int * ptr=malloc(sizeof(int)*2);
160 retval=pthread_create(&thread, &nattr, (void * (*)(void *)) &initDSMthread, ptr);
165 pthread_attr_destroy(&nattr);